From cea3c5ba09390f519e3ed86248b8845ce605d76d Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sat, 22 Feb 2025 23:15:00 +0800 Subject: [PATCH] update nodejs express server samples --- .../nodejs-express-server/.eslintrc.json | 2 +- .../.openapi-generator/FILES | 19 ++++++++ .../.openapi-generator/VERSION | 2 +- .../nodejs-express-server/api/openapi.yaml | 45 +++++++++++-------- .../petstore/nodejs-express-server/config.js | 6 +-- .../nodejs-express-server/package.json | 1 - 6 files changed, 50 insertions(+), 25 deletions(-) create mode 100644 samples/server/petstore/nodejs-express-server/.openapi-generator/FILES diff --git a/samples/server/petstore/nodejs-express-server/.eslintrc.json b/samples/server/petstore/nodejs-express-server/.eslintrc.json index 6d8abec4c52..ff2c4965246 100644 --- a/samples/server/petstore/nodejs-express-server/.eslintrc.json +++ b/samples/server/petstore/nodejs-express-server/.eslintrc.json @@ -1,7 +1,7 @@ // Use this file as a starting point for your project's .eslintrc. // Copy this file, and add rule overrides as needed. { - "extends": "airbnb", + "extends": "airbnb-base", "rules": { "no-console": "off" } diff --git a/samples/server/petstore/nodejs-express-server/.openapi-generator/FILES b/samples/server/petstore/nodejs-express-server/.openapi-generator/FILES new file mode 100644 index 00000000000..2cb9330a634 --- /dev/null +++ b/samples/server/petstore/nodejs-express-server/.openapi-generator/FILES @@ -0,0 +1,19 @@ +.eslintrc.json +README.md +api/openapi.yaml +config.js +controllers/Controller.js +controllers/PetController.js +controllers/StoreController.js +controllers/UserController.js +controllers/index.js +expressServer.js +index.js +logger.js +package.json +services/PetService.js +services/Service.js +services/StoreService.js +services/UserService.js +services/index.js +utils/openapiRouter.js diff --git a/samples/server/petstore/nodejs-express-server/.openapi-generator/VERSION b/samples/server/petstore/nodejs-express-server/.openapi-generator/VERSION index 71d2eb1c7fc..de37f5c4cf5 100644 --- a/samples/server/petstore/nodejs-express-server/.openapi-generator/VERSION +++ b/samples/server/petstore/nodejs-express-server/.openapi-generator/VERSION @@ -1 +1 @@ -5.0.0-SNAPSHOT +7.12.0-SNAPSHOT diff --git a/samples/server/petstore/nodejs-express-server/api/openapi.yaml b/samples/server/petstore/nodejs-express-server/api/openapi.yaml index 6fa9dd7eed5..22d5c5fb700 100644 --- a/samples/server/petstore/nodejs-express-server/api/openapi.yaml +++ b/samples/server/petstore/nodejs-express-server/api/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.1 info: - description: This is a sample server Petstore server. For this sample, you can use - the api key `special-key` to test the authorization filters. + description: "This is a sample server Petstore server. For this sample, you can\ + \ use the api key `special-key` to test the authorization filters." license: name: Apache-2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html @@ -122,8 +122,8 @@ paths: /pet/findByTags: get: deprecated: true - description: Multiple tags can be provided with comma separated strings. Use - tag1, tag2, tag3 for testing. + description: "Multiple tags can be provided with comma separated strings. Use\ + \ tag1, tag2, tag3 for testing." operationId: findPetsByTags parameters: - description: Tags to filter by @@ -235,13 +235,7 @@ paths: content: application/x-www-form-urlencoded: schema: - properties: - name: - description: Updated name of the pet - type: string - status: - description: Updated status of the pet - type: string + $ref: '#/components/schemas/updatePetWithForm_request' responses: "405": content: {} @@ -269,14 +263,7 @@ paths: content: multipart/form-data: schema: - properties: - additionalMetadata: - description: Additional data to pass to server - type: string - file: - description: file to upload - format: binary - type: string + $ref: '#/components/schemas/uploadFile_request' responses: "200": content: @@ -767,6 +754,25 @@ components: type: string title: An uploaded response type: object + updatePetWithForm_request: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + type: object + uploadFile_request: + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string + type: object securitySchemes: petstore_auth: flows: @@ -780,3 +786,4 @@ components: in: header name: api_key type: apiKey +x-original-swagger-version: "2.0" diff --git a/samples/server/petstore/nodejs-express-server/config.js b/samples/server/petstore/nodejs-express-server/config.js index a2348b28ca9..a706d573e4e 100644 --- a/samples/server/petstore/nodejs-express-server/config.js +++ b/samples/server/petstore/nodejs-express-server/config.js @@ -2,9 +2,9 @@ const path = require('path'); const config = { ROOT_DIR: __dirname, - URL_PORT: 3000, - URL_PATH: 'http://localhost', - BASE_VERSION: 'v2', + URL_PORT: 8080, + URL_PATH: 'http://petstore.swagger.io', + BASE_VERSION: '/v2', CONTROLLER_DIRECTORY: path.join(__dirname, 'controllers'), PROJECT_DIR: __dirname, }; diff --git a/samples/server/petstore/nodejs-express-server/package.json b/samples/server/petstore/nodejs-express-server/package.json index a92a9cb222d..331d819aa69 100644 --- a/samples/server/petstore/nodejs-express-server/package.json +++ b/samples/server/petstore/nodejs-express-server/package.json @@ -27,7 +27,6 @@ "winston": "^3.2.1" }, "devDependencies": { - "axios": "^0.19.0", "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "eslint": "^5.16.0",