Skip to content

Commit

Permalink
fix: generate swagger script
Browse files Browse the repository at this point in the history
  • Loading branch information
zlatanpham committed Aug 9, 2024
1 parent a3a6fac commit a4436dc
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"cypress:open": "cypress open",
"release": "standard-version -a",
"preinstall": "npx only-allow pnpm",
"generate:api": "orval --config ./orval.config.js",
"fetch-definitions": "swagger-typescript-api --no-client -p ./src/libs/swagger.json -o ./types -n schema.ts",
"prepare": "husky",
"clean:install": "rimraf node_modules pnpm-lock.yaml && pnpm install"
},
Expand Down
136 changes: 136 additions & 0 deletions src/libs/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Profile server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"version": "0.01",
"title": "Swagger Users",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"email": "[email protected]"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "localhost:3000",
"basePath": "/api",
"tags": [
{
"name": "pet",
"description": "Everything about your Pets",
"externalDocs": {
"description": "Find out more",
"url": "http://swagger.io"
}
},
{
"name": "store",
"description": "Access to Petstore orders"
},
{
"name": "user",
"description": "Operations about user",
"externalDocs": {
"description": "Find out more about our store",
"url": "http://swagger.io"
}
}
],
"schemes": ["https", "http"],
"paths": {
"/users": {
"get": {
"tags": ["user"],
"summary": "Get users",
"operationId": "findgetUsers",
"produces": ["application/json", "application/xml"],
"parameters": [],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/User"
}
}
},
"400": {
"description": "Invalid status value"
}
}
}
}
},
"securityDefinitions": {
"api_key": {
"type": "apiKey",
"name": "api_key",
"in": "header"
},
"petstore_auth": {
"type": "oauth2",
"authorizationUrl": "https://petstore.swagger.io/oauth/authorize",
"flow": "implicit",
"scopes": {
"read:pets": "read your pets",
"write:pets": "modify pets in your account"
}
}
},
"definitions": {
"ApiResponse": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"type": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"User": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"avatar": {
"type": "string"
},
"email": {
"type": "string"
},
"title": {
"type": "string"
},
"department": {
"type": "string"
},
"role": {
"type": "string"
},
"status": {
"type": "string"
}
},
"xml": {
"name": "User"
}
}
},
"externalDocs": {
"description": "Find out more about Swagger",
"url": "http://swagger.io"
}
}
29 changes: 29 additions & 0 deletions types/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable */
/* tslint:disable */
/*
* ---------------------------------------------------------------
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
* ## ##
* ## AUTHOR: acacode ##
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
* ---------------------------------------------------------------
*/

export interface ApiResponse {
/** @format int32 */
code?: number
type?: string
message?: string
}

export interface User {
/** @format int64 */
id?: number
name?: string
avatar?: string
email?: string
title?: string
department?: string
role?: string
status?: string
}

0 comments on commit a4436dc

Please sign in to comment.