From 6d0a13427f9dc0ec61b4d5d08a960ff724093b26 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 4 Jun 2019 14:20:30 +0800 Subject: [PATCH 1/3] mark nodejs-server as deprecated --- bin/nodejs-petstore-google-cloud-functions.sh | 2 +- bin/nodejs-petstore-server.sh | 2 +- .../languages/NodeJSServerCodegen.java | 13 +- .../.openapi-generator/VERSION | 2 +- .../api/openapi.yaml | 633 +++++++++--------- .../controllers/Pet.js | 12 +- .../controllers/Store.js | 4 +- .../controllers/User.js | 16 +- .../service/PetService.js | 12 +- .../service/StoreService.js | 4 +- .../service/UserService.js | 16 +- .../nodejs/.openapi-generator/VERSION | 2 +- .../server/petstore/nodejs/api/openapi.yaml | 19 +- .../server/petstore/nodejs/controllers/Pet.js | 12 +- .../petstore/nodejs/controllers/Store.js | 4 +- .../petstore/nodejs/controllers/User.js | 16 +- .../petstore/nodejs/service/PetService.js | 12 +- .../petstore/nodejs/service/StoreService.js | 4 +- .../petstore/nodejs/service/UserService.js | 16 +- 19 files changed, 417 insertions(+), 384 deletions(-) diff --git a/bin/nodejs-petstore-google-cloud-functions.sh b/bin/nodejs-petstore-google-cloud-functions.sh index 80e120270584..bfb02d960dca 100755 --- a/bin/nodejs-petstore-google-cloud-functions.sh +++ b/bin/nodejs-petstore-google-cloud-functions.sh @@ -27,6 +27,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@" +ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server-deprecated --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/nodejs-petstore-server.sh b/bin/nodejs-petstore-server.sh index 2dfc8f327c71..fbbed3e46f1e 100755 --- a/bin/nodejs-petstore-server.sh +++ b/bin/nodejs-petstore-server.sh @@ -27,6 +27,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/nodejs -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server -o samples/server/petstore/nodejs -Dservice $@" +ags="generate -t modules/openapi-generator/src/main/resources/nodejs -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-server-deprecated -o samples/server/petstore/nodejs -Dservice $@" java $JAVA_OPTS -jar $executable $ags diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NodeJSServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NodeJSServerCodegen.java index 896f0837e572..eccb5a0cb3ab 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NodeJSServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/NodeJSServerCodegen.java @@ -28,6 +28,8 @@ import io.swagger.v3.oas.models.info.Info; import org.openapitools.codegen.*; import org.openapitools.codegen.config.GeneratorProperties; +import org.openapitools.codegen.meta.GeneratorMetadata; +import org.openapitools.codegen.meta.Stability; import org.openapitools.codegen.utils.URLPathUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,6 +60,11 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig public NodeJSServerCodegen() { super(); + // mark the generator as deprecated in the documentation + generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata) + .stability(Stability.DEPRECATED) + .build(); + // set the output folder here outputFolder = "generated-code/nodejs"; @@ -142,7 +149,7 @@ public CodegenType getTag() { */ @Override public String getName() { - return "nodejs-server"; + return "nodejs-server-deprecated"; } /** @@ -153,7 +160,7 @@ public String getName() { */ @Override public String getHelp() { - return "Generates a nodejs server library using the swagger-tools project. By default, " + + return "[DEPRECATED] Generates a nodejs server library using the swagger-tools project. By default, " + "it will also generate service classes--which you can disable with the `-Dnoservice` environment variable."; } @@ -303,6 +310,8 @@ public void processOpts() { message.append(System.lineSeparator()).append(System.lineSeparator()) .append("=======================================================================================") .append(System.lineSeparator()) + .append("IMPORTANT: The nodejs-server generator has been deprecated.") + .append(System.lineSeparator()) .append("Currently, Node.js server doesn't work as its dependency doesn't support OpenAPI Spec3.") .append(System.lineSeparator()) .append("For further details, see https://github.com/OpenAPITools/openapi-generator/issues/34") diff --git a/samples/server/petstore/nodejs-google-cloud-functions/.openapi-generator/VERSION b/samples/server/petstore/nodejs-google-cloud-functions/.openapi-generator/VERSION index 096bf47efe31..d96260ba335d 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/.openapi-generator/VERSION +++ b/samples/server/petstore/nodejs-google-cloud-functions/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.0-SNAPSHOT \ No newline at end of file +4.0.2-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/nodejs-google-cloud-functions/api/openapi.yaml b/samples/server/petstore/nodejs-google-cloud-functions/api/openapi.yaml index 8a31b8d5b865..3a1276ec5f87 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/api/openapi.yaml +++ b/samples/server/petstore/nodejs-google-cloud-functions/api/openapi.yaml @@ -1,29 +1,26 @@ openapi: 3.0.1 info: - title: OpenAPI Petstore - 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: http://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore version: 1.0.0 servers: - url: http://petstore.swagger.io/v2 tags: -- name: pet - description: Everything about your Pets -- name: store - description: Access to Petstore orders -- name: user - description: Operations about user +- description: Everything about your Pets + name: pet +- description: Access to Petstore orders + name: store +- description: Operations about user + name: user paths: /pet: - put: - tags: - - pet - summary: Update an existing pet - operationId: updatePet + post: + operationId: addPet requestBody: - description: Pet object that needs to be added to the store content: application/json: schema: @@ -31,29 +28,24 @@ paths: application/xml: schema: $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store required: true responses: - 400: - description: Invalid ID supplied - content: {} - 404: - description: Pet not found - content: {} 405: - description: Validation exception content: {} + description: Invalid input security: - petstore_auth: - write:pets - read:pets - x-openapi-router-controller: Pet - post: + summary: Add a new pet to the store tags: - pet - summary: Add a new pet to the store - operationId: addPet + x-codegen-request-body-name: body + x-swagger-router-controller: Pet + put: + operationId: updatePet requestBody: - description: Pet object that needs to be added to the store content: application/json: schema: @@ -61,118 +53,154 @@ paths: application/xml: schema: $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store required: true responses: + 400: + content: {} + description: Invalid ID supplied + 404: + content: {} + description: Pet not found 405: - description: Invalid input content: {} + description: Validation exception security: - petstore_auth: - write:pets - read:pets - x-openapi-router-controller: Pet - /pet/findByStatus: - get: + summary: Update an existing pet tags: - pet - summary: Finds Pets by status + x-codegen-request-body-name: body + x-swagger-router-controller: Pet + /pet/findByStatus: + get: description: Multiple status values can be provided with comma separated strings operationId: findPetsByStatus parameters: - - name: status + - description: Status values that need to be considered for filter + explode: false in: query - description: Status values that need to be considered for filter + name: status required: true - explode: false schema: - type: array items: - type: string default: available enum: - available - pending - sold + type: string + type: array + style: form responses: 200: - description: successful operation content: application/xml: schema: - type: array items: $ref: '#/components/schemas/Pet' + type: array application/json: schema: - type: array items: $ref: '#/components/schemas/Pet' + type: array + description: successful operation 400: - description: Invalid status value content: {} + description: Invalid status value security: - petstore_auth: - write:pets - read:pets - x-openapi-router-controller: Pet - /pet/findByTags: - get: + summary: Finds Pets by status tags: - pet - summary: Finds Pets by tags - description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + x-swagger-router-controller: Pet + /pet/findByTags: + get: + deprecated: true + description: Multiple tags can be provided with comma separated strings. Use + tag1, tag2, tag3 for testing. operationId: findPetsByTags parameters: - - name: tags + - description: Tags to filter by + explode: false in: query - description: Tags to filter by + name: tags required: true - explode: false schema: - type: array items: type: string + type: array + style: form responses: 200: - description: successful operation content: application/xml: schema: - type: array items: $ref: '#/components/schemas/Pet' + type: array application/json: schema: - type: array items: $ref: '#/components/schemas/Pet' + type: array + description: successful operation 400: - description: Invalid tag value content: {} - deprecated: true + description: Invalid tag value security: - petstore_auth: - write:pets - read:pets - x-openapi-router-controller: Pet + summary: Finds Pets by tags + tags: + - pet + x-swagger-router-controller: Pet /pet/{petId}: - get: + delete: + operationId: deletePet + parameters: + - in: header + name: api_key + schema: + type: string + - description: Pet id to delete + in: path + name: petId + required: true + schema: + format: int64 + type: integer + responses: + 400: + content: {} + description: Invalid pet value + security: + - petstore_auth: + - write:pets + - read:pets + summary: Deletes a pet tags: - pet - summary: Find pet by ID + x-swagger-router-controller: Pet + get: description: Returns a single pet operationId: getPetById parameters: - - name: petId + - description: ID of pet to return in: path - description: ID of pet to return + name: petId required: true schema: - type: integer format: int64 + type: integer responses: 200: - description: successful operation content: application/xml: schema: @@ -180,148 +208,122 @@ paths: application/json: schema: $ref: '#/components/schemas/Pet' + description: successful operation 400: - description: Invalid ID supplied content: {} + description: Invalid ID supplied 404: - description: Pet not found content: {} + description: Pet not found security: - api_key: [] - x-openapi-router-controller: Pet - post: + summary: Find pet by ID tags: - pet - summary: Updates a pet in the store with form data + x-swagger-router-controller: Pet + post: operationId: updatePetWithForm parameters: - - name: petId + - description: ID of pet that needs to be updated in: path - description: ID of pet that needs to be updated + name: petId required: true schema: - type: integer format: int64 + type: integer requestBody: content: application/x-www-form-urlencoded: schema: properties: name: - type: string description: Updated name of the pet - status: type: string + status: description: Updated status of the pet + type: string responses: 405: - description: Invalid input content: {} + description: Invalid input security: - petstore_auth: - write:pets - read:pets - x-openapi-router-controller: Pet - delete: + summary: Updates a pet in the store with form data tags: - pet - summary: Deletes a pet - operationId: deletePet - parameters: - - name: api_key - in: header - schema: - type: string - - name: petId - in: path - description: Pet id to delete - required: true - schema: - type: integer - format: int64 - responses: - 400: - description: Invalid pet value - content: {} - security: - - petstore_auth: - - write:pets - - read:pets - x-openapi-router-controller: Pet + x-swagger-router-controller: Pet /pet/{petId}/uploadImage: post: - tags: - - pet - summary: uploads an image operationId: uploadFile parameters: - - name: petId + - description: ID of pet to update in: path - description: ID of pet to update + name: petId required: true schema: - type: integer format: int64 + type: integer requestBody: content: multipart/form-data: schema: properties: additionalMetadata: - type: string description: Additional data to pass to server - file: type: string + file: description: file to upload format: binary + type: string responses: 200: - description: successful operation content: application/json: schema: $ref: '#/components/schemas/ApiResponse' + description: successful operation security: - petstore_auth: - write:pets - read:pets - x-openapi-router-controller: Pet + summary: uploads an image + tags: + - pet + x-swagger-router-controller: Pet /store/inventory: get: - tags: - - store - summary: Returns pet inventories by status description: Returns a map of status codes to quantities operationId: getInventory responses: 200: - description: successful operation content: application/json: schema: - type: object additionalProperties: - type: integer format: int32 + type: integer + type: object + description: successful operation security: - api_key: [] - x-openapi-router-controller: Store - /store/order: - post: + summary: Returns pet inventories by status tags: - store - summary: Place an order for a pet + x-swagger-router-controller: Store + /store/order: + post: operationId: placeOrder requestBody: - description: order placed for purchasing the pet content: '*/*': schema: $ref: '#/components/schemas/Order' + description: order placed for purchasing the pet required: true responses: 200: - description: successful operation content: application/xml: schema: @@ -329,30 +331,54 @@ paths: application/json: schema: $ref: '#/components/schemas/Order' + description: successful operation 400: - description: Invalid Order content: {} - x-openapi-router-controller: Store + description: Invalid Order + summary: Place an order for a pet + tags: + - store + x-codegen-request-body-name: body + x-swagger-router-controller: Store /store/order/{orderId}: - get: + delete: + description: For valid response try integer IDs with value < 1000. Anything + above 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - description: ID of the order that needs to be deleted + in: path + name: orderId + required: true + schema: + type: string + responses: + 400: + content: {} + description: Invalid ID supplied + 404: + content: {} + description: Order not found + summary: Delete purchase order by ID tags: - store - summary: Find purchase order by ID - description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + x-swagger-router-controller: Store + get: + description: For valid response try integer IDs with value <= 5 or > 10. Other + values will generated exceptions operationId: getOrderById parameters: - - name: orderId + - description: ID of pet that needs to be fetched in: path - description: ID of pet that needs to be fetched + name: orderId required: true schema: + format: int64 maximum: 5 minimum: 1 type: integer - format: int64 responses: 200: - description: successful operation content: application/xml: schema: @@ -360,164 +386,167 @@ paths: application/json: schema: $ref: '#/components/schemas/Order' + description: successful operation 400: - description: Invalid ID supplied content: {} + description: Invalid ID supplied 404: - description: Order not found content: {} - x-openapi-router-controller: Store - delete: + description: Order not found + summary: Find purchase order by ID tags: - store - summary: Delete purchase order by ID - description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - operationId: deleteOrder - parameters: - - name: orderId - in: path - description: ID of the order that needs to be deleted - required: true - schema: - type: string - responses: - 400: - description: Invalid ID supplied - content: {} - 404: - description: Order not found - content: {} - x-openapi-router-controller: Store + x-swagger-router-controller: Store /user: post: - tags: - - user - summary: Create user description: This can only be done by the logged in user. operationId: createUser requestBody: - description: Created user object content: '*/*': schema: $ref: '#/components/schemas/User' + description: Created user object required: true responses: default: - description: successful operation content: {} - x-openapi-router-controller: User - /user/createWithArray: - post: + description: successful operation + summary: Create user tags: - user - summary: Creates list of users with given input array + x-codegen-request-body-name: body + x-swagger-router-controller: User + /user/createWithArray: + post: operationId: createUsersWithArrayInput requestBody: - description: List of user object content: '*/*': schema: - type: array items: $ref: '#/components/schemas/User' + type: array + description: List of user object required: true responses: default: - description: successful operation content: {} - x-openapi-router-controller: User - /user/createWithList: - post: + description: successful operation + summary: Creates list of users with given input array tags: - user - summary: Creates list of users with given input array + x-codegen-request-body-name: body + x-swagger-router-controller: User + /user/createWithList: + post: operationId: createUsersWithListInput requestBody: - description: List of user object content: '*/*': schema: - type: array items: $ref: '#/components/schemas/User' + type: array + description: List of user object required: true responses: default: - description: successful operation content: {} - x-openapi-router-controller: User - /user/login: - get: + description: successful operation + summary: Creates list of users with given input array tags: - user - summary: Logs user into the system + x-codegen-request-body-name: body + x-swagger-router-controller: User + /user/login: + get: operationId: loginUser parameters: - - name: username + - description: The user name for login in: query - description: The user name for login + name: username required: true schema: type: string - - name: password + - description: The password for login in clear text in: query - description: The password for login in clear text + name: password required: true schema: type: string responses: 200: + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string description: successful operation headers: X-Rate-Limit: description: calls per hour allowed by the user schema: - type: integer format: int32 + type: integer X-Expires-After: description: date in UTC when toekn expires schema: - type: string format: date-time - content: - application/xml: - schema: - type: string - application/json: - schema: type: string 400: - description: Invalid username/password supplied content: {} - x-openapi-router-controller: User - /user/logout: - get: + description: Invalid username/password supplied + summary: Logs user into the system tags: - user - summary: Logs out current logged in user session + x-swagger-router-controller: User + /user/logout: + get: operationId: logoutUser responses: default: - description: successful operation content: {} - x-openapi-router-controller: User + description: successful operation + summary: Logs out current logged in user session + tags: + - user + x-swagger-router-controller: User /user/{username}: - get: + delete: + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - description: The name that needs to be deleted + in: path + name: username + required: true + schema: + type: string + responses: + 400: + content: {} + description: Invalid username supplied + 404: + content: {} + description: User not found + summary: Delete user tags: - user - summary: Get user by user name + x-swagger-router-controller: User + get: operationId: getUserByName parameters: - - name: username + - description: The name that needs to be fetched. Use user1 for testing. in: path - description: The name that needs to be fetched. Use user1 for testing. + name: username required: true schema: type: string responses: 200: - description: successful operation content: application/xml: schema: @@ -525,122 +554,114 @@ paths: application/json: schema: $ref: '#/components/schemas/User' + description: successful operation 400: - description: Invalid username supplied content: {} + description: Invalid username supplied 404: - description: User not found content: {} - x-openapi-router-controller: User - put: + description: User not found + summary: Get user by user name tags: - user - summary: Updated user + x-swagger-router-controller: User + put: description: This can only be done by the logged in user. operationId: updateUser parameters: - - name: username + - description: name that need to be deleted in: path - description: name that need to be deleted + name: username required: true schema: type: string requestBody: - description: Updated user object content: '*/*': schema: $ref: '#/components/schemas/User' + description: Updated user object required: true responses: 400: - description: Invalid user supplied content: {} + description: Invalid user supplied 404: - description: User not found content: {} - x-openapi-router-controller: User - delete: + description: User not found + summary: Updated user tags: - user - summary: Delete user - description: This can only be done by the logged in user. - operationId: deleteUser - parameters: - - name: username - in: path - description: The name that needs to be deleted - required: true - schema: - type: string - responses: - 400: - description: Invalid username supplied - content: {} - 404: - description: User not found - content: {} - x-openapi-router-controller: User + x-codegen-request-body-name: body + x-swagger-router-controller: User components: schemas: Order: - title: Pet Order - type: object + description: An order for a pets from the pet store + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2000-01-23T04:56:07.000+00:00 + complete: false + status: placed properties: id: - type: integer format: int64 - petId: type: integer + petId: format: int64 - quantity: type: integer + quantity: format: int32 + type: integer shipDate: - type: string format: date-time - status: type: string + status: description: Order Status enum: - placed - approved - delivered + type: string complete: - type: boolean default: false - description: An order for a pets from the pet store - example: - petId: 6 - quantity: 1 - id: 0 - shipDate: 2000-01-23T04:56:07.000+00:00 - complete: false - status: placed + type: boolean + title: Pet Order + type: object xml: name: Order Category: - title: Pet category - type: object + description: A category for a pet + example: + name: name + id: 6 properties: id: - type: integer format: int64 + type: integer name: type: string - description: A category for a pet - example: - name: name - id: 6 + title: Pet category + type: object xml: name: Category User: - title: a User - type: object + description: A User who is purchasing from the pet store + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username properties: id: - type: integer format: int64 + type: integer username: type: string firstName: @@ -654,116 +675,108 @@ components: phone: type: string userStatus: - type: integer description: User Status format: int32 - description: A User who is purchasing from the pet store - example: - firstName: firstName - lastName: lastName - password: password - userStatus: 6 - phone: phone - id: 0 - email: email - username: username + type: integer + title: a User + type: object xml: name: User Tag: - title: Pet Tag - type: object + description: A tag for a pet + example: + name: name + id: 1 properties: id: - type: integer format: int64 + type: integer name: type: string - description: A tag for a pet - example: - name: name - id: 1 + title: Pet Tag + type: object xml: name: Tag Pet: - title: a Pet - required: - - name - - photoUrls - type: object + description: A pet for sale in the pet store + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available properties: id: - type: integer format: int64 + type: integer category: $ref: '#/components/schemas/Category' name: - type: string example: doggie + type: string photoUrls: + items: + type: string type: array xml: name: photoUrl wrapped: true - items: - type: string tags: + items: + $ref: '#/components/schemas/Tag' type: array xml: name: tag wrapped: true - items: - $ref: '#/components/schemas/Tag' status: - type: string description: pet status in the store enum: - available - pending - sold - description: A pet for sale in the pet store - example: - photoUrls: - - photoUrls - - photoUrls - name: doggie - id: 0 - category: - name: name - id: 6 - tags: - - name: name - id: 1 - - name: name - id: 1 - status: available + type: string + required: + - name + - photoUrls + title: a Pet + type: object xml: name: Pet ApiResponse: - title: An uploaded response - type: object + description: Describes the result of uploading an image resource + example: + code: 0 + type: type + message: message properties: code: - type: integer format: int32 + type: integer type: type: string message: type: string - description: Describes the result of uploading an image resource - example: - code: 0 - type: type - message: message + title: An uploaded response + type: object securitySchemes: petstore_auth: - type: oauth2 flows: implicit: authorizationUrl: http://petstore.swagger.io/api/oauth/dialog scopes: write:pets: modify pets in your account read:pets: read your pets + type: oauth2 api_key: - type: apiKey - name: api_key in: header + name: api_key + type: apiKey diff --git a/samples/server/petstore/nodejs-google-cloud-functions/controllers/Pet.js b/samples/server/petstore/nodejs-google-cloud-functions/controllers/Pet.js index 53d029ce27ca..f3286ea17349 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/controllers/Pet.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/controllers/Pet.js @@ -4,8 +4,8 @@ var utils = require('../utils/writer.js'); var Pet = require('../service/PetService'); module.exports.addPet = function addPet (req, res, next) { - var pet = req.swagger.params['Pet'].value; - Pet.addPet(pet) + var body = req.swagger.params['body'].value; + Pet.addPet(body) .then(function (response) { utils.writeJson(res, response); }) @@ -16,8 +16,8 @@ module.exports.addPet = function addPet (req, res, next) { module.exports.deletePet = function deletePet (req, res, next) { var petId = req.swagger.params['petId'].value; - var api_key = req.swagger.params['api_key'].value; - Pet.deletePet(petId,api_key) + var apiUnderscorekey = req.swagger.params['api_key'].value; + Pet.deletePet(petId,apiUnderscorekey) .then(function (response) { utils.writeJson(res, response); }) @@ -60,8 +60,8 @@ module.exports.getPetById = function getPetById (req, res, next) { }; module.exports.updatePet = function updatePet (req, res, next) { - var pet = req.swagger.params['Pet'].value; - Pet.updatePet(pet) + var body = req.swagger.params['body'].value; + Pet.updatePet(body) .then(function (response) { utils.writeJson(res, response); }) diff --git a/samples/server/petstore/nodejs-google-cloud-functions/controllers/Store.js b/samples/server/petstore/nodejs-google-cloud-functions/controllers/Store.js index eb403b6b87dd..b781e64556fd 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/controllers/Store.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/controllers/Store.js @@ -36,8 +36,8 @@ module.exports.getOrderById = function getOrderById (req, res, next) { }; module.exports.placeOrder = function placeOrder (req, res, next) { - var order = req.swagger.params['Order'].value; - Store.placeOrder(order) + var body = req.swagger.params['body'].value; + Store.placeOrder(body) .then(function (response) { utils.writeJson(res, response); }) diff --git a/samples/server/petstore/nodejs-google-cloud-functions/controllers/User.js b/samples/server/petstore/nodejs-google-cloud-functions/controllers/User.js index 6a67f0ea212e..f444efa38e58 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/controllers/User.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/controllers/User.js @@ -4,8 +4,8 @@ var utils = require('../utils/writer.js'); var User = require('../service/UserService'); module.exports.createUser = function createUser (req, res, next) { - var user = req.swagger.params['User'].value; - User.createUser(user) + var body = req.swagger.params['body'].value; + User.createUser(body) .then(function (response) { utils.writeJson(res, response); }) @@ -15,8 +15,8 @@ module.exports.createUser = function createUser (req, res, next) { }; module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (req, res, next) { - var user = req.swagger.params['User'].value; - User.createUsersWithArrayInput(user) + var body = req.swagger.params['body'].value; + User.createUsersWithArrayInput(body) .then(function (response) { utils.writeJson(res, response); }) @@ -26,8 +26,8 @@ module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (r }; module.exports.createUsersWithListInput = function createUsersWithListInput (req, res, next) { - var user = req.swagger.params['User'].value; - User.createUsersWithListInput(user) + var body = req.swagger.params['body'].value; + User.createUsersWithListInput(body) .then(function (response) { utils.writeJson(res, response); }) @@ -82,8 +82,8 @@ module.exports.logoutUser = function logoutUser (req, res, next) { module.exports.updateUser = function updateUser (req, res, next) { var username = req.swagger.params['username'].value; - var user = req.swagger.params['User'].value; - User.updateUser(username,user) + var body = req.swagger.params['body'].value; + User.updateUser(username,body) .then(function (response) { utils.writeJson(res, response); }) diff --git a/samples/server/petstore/nodejs-google-cloud-functions/service/PetService.js b/samples/server/petstore/nodejs-google-cloud-functions/service/PetService.js index e4a0219ab80d..6a276ef1e8cc 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/service/PetService.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/service/PetService.js @@ -4,10 +4,10 @@ /** * Add a new pet to the store * - * pet Pet Pet object that needs to be added to the store + * body Pet Pet object that needs to be added to the store * no response value expected for this operation **/ -exports.addPet = function(pet) { +exports.addPet = function(body) { return new Promise(function(resolve, reject) { resolve(); }); @@ -18,10 +18,10 @@ exports.addPet = function(pet) { * Deletes a pet * * petId Long Pet id to delete - * api_key String (optional) + * apiUnderscorekey String (optional) * no response value expected for this operation **/ -exports.deletePet = function(petId,api_key) { +exports.deletePet = function(petId,apiUnderscorekey) { return new Promise(function(resolve, reject) { resolve(); }); @@ -139,10 +139,10 @@ exports.getPetById = function(petId) { /** * Update an existing pet * - * pet Pet Pet object that needs to be added to the store + * body Pet Pet object that needs to be added to the store * no response value expected for this operation **/ -exports.updatePet = function(pet) { +exports.updatePet = function(body) { return new Promise(function(resolve, reject) { resolve(); }); diff --git a/samples/server/petstore/nodejs-google-cloud-functions/service/StoreService.js b/samples/server/petstore/nodejs-google-cloud-functions/service/StoreService.js index 50a2768d9051..afdbe501622d 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/service/StoreService.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/service/StoreService.js @@ -63,10 +63,10 @@ exports.getOrderById = function(orderId) { /** * Place an order for a pet * - * order Order order placed for purchasing the pet + * body Order order placed for purchasing the pet * returns Order **/ -exports.placeOrder = function(order) { +exports.placeOrder = function(body) { return new Promise(function(resolve, reject) { var examples = {}; examples['application/json'] = { diff --git a/samples/server/petstore/nodejs-google-cloud-functions/service/UserService.js b/samples/server/petstore/nodejs-google-cloud-functions/service/UserService.js index ae482204a21b..9753092fb905 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/service/UserService.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/service/UserService.js @@ -5,10 +5,10 @@ * Create user * This can only be done by the logged in user. * - * user User Created user object + * body User Created user object * no response value expected for this operation **/ -exports.createUser = function(user) { +exports.createUser = function(body) { return new Promise(function(resolve, reject) { resolve(); }); @@ -18,10 +18,10 @@ exports.createUser = function(user) { /** * Creates list of users with given input array * - * user List List of user object + * body List List of user object * no response value expected for this operation **/ -exports.createUsersWithArrayInput = function(user) { +exports.createUsersWithArrayInput = function(body) { return new Promise(function(resolve, reject) { resolve(); }); @@ -31,10 +31,10 @@ exports.createUsersWithArrayInput = function(user) { /** * Creates list of users with given input array * - * user List List of user object + * body List List of user object * no response value expected for this operation **/ -exports.createUsersWithListInput = function(user) { +exports.createUsersWithListInput = function(body) { return new Promise(function(resolve, reject) { resolve(); }); @@ -119,10 +119,10 @@ exports.logoutUser = function() { * This can only be done by the logged in user. * * username String name that need to be deleted - * user User Updated user object + * body User Updated user object * no response value expected for this operation **/ -exports.updateUser = function(username,user) { +exports.updateUser = function(username,body) { return new Promise(function(resolve, reject) { resolve(); }); diff --git a/samples/server/petstore/nodejs/.openapi-generator/VERSION b/samples/server/petstore/nodejs/.openapi-generator/VERSION index 0628777500bd..d96260ba335d 100644 --- a/samples/server/petstore/nodejs/.openapi-generator/VERSION +++ b/samples/server/petstore/nodejs/.openapi-generator/VERSION @@ -1 +1 @@ -3.1.0-SNAPSHOT \ No newline at end of file +4.0.2-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/nodejs/api/openapi.yaml b/samples/server/petstore/nodejs/api/openapi.yaml index 877989080caf..3a1276ec5f87 100644 --- a/samples/server/petstore/nodejs/api/openapi.yaml +++ b/samples/server/petstore/nodejs/api/openapi.yaml @@ -1,6 +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: http://www.apache.org/licenses/LICENSE-2.0.html @@ -40,6 +41,7 @@ paths: summary: Add a new pet to the store tags: - pet + x-codegen-request-body-name: body x-swagger-router-controller: Pet put: operationId: updatePet @@ -70,6 +72,7 @@ paths: summary: Update an existing pet tags: - pet + x-codegen-request-body-name: body x-swagger-router-controller: Pet /pet/findByStatus: get: @@ -119,7 +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 @@ -334,10 +338,12 @@ paths: summary: Place an order for a pet tags: - store + x-codegen-request-body-name: body x-swagger-router-controller: Store /store/order/{orderId}: delete: - description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + description: For valid response try integer IDs with value < 1000. Anything + above 1000 or nonintegers will generate API errors operationId: deleteOrder parameters: - description: ID of the order that needs to be deleted @@ -358,7 +364,8 @@ paths: - store x-swagger-router-controller: Store get: - description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + description: For valid response try integer IDs with value <= 5 or > 10. Other + values will generated exceptions operationId: getOrderById parameters: - description: ID of pet that needs to be fetched @@ -408,6 +415,7 @@ paths: summary: Create user tags: - user + x-codegen-request-body-name: body x-swagger-router-controller: User /user/createWithArray: post: @@ -428,6 +436,7 @@ paths: summary: Creates list of users with given input array tags: - user + x-codegen-request-body-name: body x-swagger-router-controller: User /user/createWithList: post: @@ -448,6 +457,7 @@ paths: summary: Creates list of users with given input array tags: - user + x-codegen-request-body-name: body x-swagger-router-controller: User /user/login: get: @@ -582,6 +592,7 @@ paths: summary: Updated user tags: - user + x-codegen-request-body-name: body x-swagger-router-controller: User components: schemas: diff --git a/samples/server/petstore/nodejs/controllers/Pet.js b/samples/server/petstore/nodejs/controllers/Pet.js index 53d029ce27ca..f3286ea17349 100644 --- a/samples/server/petstore/nodejs/controllers/Pet.js +++ b/samples/server/petstore/nodejs/controllers/Pet.js @@ -4,8 +4,8 @@ var utils = require('../utils/writer.js'); var Pet = require('../service/PetService'); module.exports.addPet = function addPet (req, res, next) { - var pet = req.swagger.params['Pet'].value; - Pet.addPet(pet) + var body = req.swagger.params['body'].value; + Pet.addPet(body) .then(function (response) { utils.writeJson(res, response); }) @@ -16,8 +16,8 @@ module.exports.addPet = function addPet (req, res, next) { module.exports.deletePet = function deletePet (req, res, next) { var petId = req.swagger.params['petId'].value; - var api_key = req.swagger.params['api_key'].value; - Pet.deletePet(petId,api_key) + var apiUnderscorekey = req.swagger.params['api_key'].value; + Pet.deletePet(petId,apiUnderscorekey) .then(function (response) { utils.writeJson(res, response); }) @@ -60,8 +60,8 @@ module.exports.getPetById = function getPetById (req, res, next) { }; module.exports.updatePet = function updatePet (req, res, next) { - var pet = req.swagger.params['Pet'].value; - Pet.updatePet(pet) + var body = req.swagger.params['body'].value; + Pet.updatePet(body) .then(function (response) { utils.writeJson(res, response); }) diff --git a/samples/server/petstore/nodejs/controllers/Store.js b/samples/server/petstore/nodejs/controllers/Store.js index eb403b6b87dd..b781e64556fd 100644 --- a/samples/server/petstore/nodejs/controllers/Store.js +++ b/samples/server/petstore/nodejs/controllers/Store.js @@ -36,8 +36,8 @@ module.exports.getOrderById = function getOrderById (req, res, next) { }; module.exports.placeOrder = function placeOrder (req, res, next) { - var order = req.swagger.params['Order'].value; - Store.placeOrder(order) + var body = req.swagger.params['body'].value; + Store.placeOrder(body) .then(function (response) { utils.writeJson(res, response); }) diff --git a/samples/server/petstore/nodejs/controllers/User.js b/samples/server/petstore/nodejs/controllers/User.js index 6a67f0ea212e..f444efa38e58 100644 --- a/samples/server/petstore/nodejs/controllers/User.js +++ b/samples/server/petstore/nodejs/controllers/User.js @@ -4,8 +4,8 @@ var utils = require('../utils/writer.js'); var User = require('../service/UserService'); module.exports.createUser = function createUser (req, res, next) { - var user = req.swagger.params['User'].value; - User.createUser(user) + var body = req.swagger.params['body'].value; + User.createUser(body) .then(function (response) { utils.writeJson(res, response); }) @@ -15,8 +15,8 @@ module.exports.createUser = function createUser (req, res, next) { }; module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (req, res, next) { - var user = req.swagger.params['User'].value; - User.createUsersWithArrayInput(user) + var body = req.swagger.params['body'].value; + User.createUsersWithArrayInput(body) .then(function (response) { utils.writeJson(res, response); }) @@ -26,8 +26,8 @@ module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (r }; module.exports.createUsersWithListInput = function createUsersWithListInput (req, res, next) { - var user = req.swagger.params['User'].value; - User.createUsersWithListInput(user) + var body = req.swagger.params['body'].value; + User.createUsersWithListInput(body) .then(function (response) { utils.writeJson(res, response); }) @@ -82,8 +82,8 @@ module.exports.logoutUser = function logoutUser (req, res, next) { module.exports.updateUser = function updateUser (req, res, next) { var username = req.swagger.params['username'].value; - var user = req.swagger.params['User'].value; - User.updateUser(username,user) + var body = req.swagger.params['body'].value; + User.updateUser(username,body) .then(function (response) { utils.writeJson(res, response); }) diff --git a/samples/server/petstore/nodejs/service/PetService.js b/samples/server/petstore/nodejs/service/PetService.js index e4a0219ab80d..6a276ef1e8cc 100644 --- a/samples/server/petstore/nodejs/service/PetService.js +++ b/samples/server/petstore/nodejs/service/PetService.js @@ -4,10 +4,10 @@ /** * Add a new pet to the store * - * pet Pet Pet object that needs to be added to the store + * body Pet Pet object that needs to be added to the store * no response value expected for this operation **/ -exports.addPet = function(pet) { +exports.addPet = function(body) { return new Promise(function(resolve, reject) { resolve(); }); @@ -18,10 +18,10 @@ exports.addPet = function(pet) { * Deletes a pet * * petId Long Pet id to delete - * api_key String (optional) + * apiUnderscorekey String (optional) * no response value expected for this operation **/ -exports.deletePet = function(petId,api_key) { +exports.deletePet = function(petId,apiUnderscorekey) { return new Promise(function(resolve, reject) { resolve(); }); @@ -139,10 +139,10 @@ exports.getPetById = function(petId) { /** * Update an existing pet * - * pet Pet Pet object that needs to be added to the store + * body Pet Pet object that needs to be added to the store * no response value expected for this operation **/ -exports.updatePet = function(pet) { +exports.updatePet = function(body) { return new Promise(function(resolve, reject) { resolve(); }); diff --git a/samples/server/petstore/nodejs/service/StoreService.js b/samples/server/petstore/nodejs/service/StoreService.js index 50a2768d9051..afdbe501622d 100644 --- a/samples/server/petstore/nodejs/service/StoreService.js +++ b/samples/server/petstore/nodejs/service/StoreService.js @@ -63,10 +63,10 @@ exports.getOrderById = function(orderId) { /** * Place an order for a pet * - * order Order order placed for purchasing the pet + * body Order order placed for purchasing the pet * returns Order **/ -exports.placeOrder = function(order) { +exports.placeOrder = function(body) { return new Promise(function(resolve, reject) { var examples = {}; examples['application/json'] = { diff --git a/samples/server/petstore/nodejs/service/UserService.js b/samples/server/petstore/nodejs/service/UserService.js index ae482204a21b..9753092fb905 100644 --- a/samples/server/petstore/nodejs/service/UserService.js +++ b/samples/server/petstore/nodejs/service/UserService.js @@ -5,10 +5,10 @@ * Create user * This can only be done by the logged in user. * - * user User Created user object + * body User Created user object * no response value expected for this operation **/ -exports.createUser = function(user) { +exports.createUser = function(body) { return new Promise(function(resolve, reject) { resolve(); }); @@ -18,10 +18,10 @@ exports.createUser = function(user) { /** * Creates list of users with given input array * - * user List List of user object + * body List List of user object * no response value expected for this operation **/ -exports.createUsersWithArrayInput = function(user) { +exports.createUsersWithArrayInput = function(body) { return new Promise(function(resolve, reject) { resolve(); }); @@ -31,10 +31,10 @@ exports.createUsersWithArrayInput = function(user) { /** * Creates list of users with given input array * - * user List List of user object + * body List List of user object * no response value expected for this operation **/ -exports.createUsersWithListInput = function(user) { +exports.createUsersWithListInput = function(body) { return new Promise(function(resolve, reject) { resolve(); }); @@ -119,10 +119,10 @@ exports.logoutUser = function() { * This can only be done by the logged in user. * * username String name that need to be deleted - * user User Updated user object + * body User Updated user object * no response value expected for this operation **/ -exports.updateUser = function(username,user) { +exports.updateUser = function(username,body) { return new Promise(function(resolve, reject) { resolve(); }); From a5cea5c0bea018af7e27495bd280300550882d6f Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 4 Jun 2019 16:11:27 +0800 Subject: [PATCH 2/3] update opeanpi3 script --- .../nodejs-petstore-google-cloud-functions.sh | 2 +- bin/openapi3/nodejs-petstore-server.sh | 2 +- docs/generators.md | 2 +- .../api/openapi.yaml | 203 +++++++++++------- .../controllers/Pet.js | 11 +- .../controllers/Store.js | 4 +- .../controllers/User.js | 16 +- .../service/PetService.js | 11 +- .../service/StoreService.js | 4 +- .../service/UserService.js | 16 +- .../server/petstore/nodejs/api/openapi.yaml | 203 +++++++++++------- .../server/petstore/nodejs/controllers/Pet.js | 11 +- .../petstore/nodejs/controllers/Store.js | 4 +- .../petstore/nodejs/controllers/User.js | 16 +- .../petstore/nodejs/service/PetService.js | 11 +- .../petstore/nodejs/service/StoreService.js | 4 +- .../petstore/nodejs/service/UserService.js | 16 +- 17 files changed, 325 insertions(+), 211 deletions(-) diff --git a/bin/openapi3/nodejs-petstore-google-cloud-functions.sh b/bin/openapi3/nodejs-petstore-google-cloud-functions.sh index a11e8da6c5d8..00ab32fb9ab0 100755 --- a/bin/openapi3/nodejs-petstore-google-cloud-functions.sh +++ b/bin/openapi3/nodejs-petstore-google-cloud-functions.sh @@ -27,6 +27,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g nodejs-server --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@" +ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g nodejs-server-deprecated --additional-properties=googleCloudFunctions=true -o samples/server/petstore/nodejs-google-cloud-functions -Dservice $@" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/nodejs-petstore-server.sh b/bin/openapi3/nodejs-petstore-server.sh index df83e4ebfa61..a987aced3575 100755 --- a/bin/openapi3/nodejs-petstore-server.sh +++ b/bin/openapi3/nodejs-petstore-server.sh @@ -27,6 +27,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/nodejs -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g nodejs-server -o samples/server/petstore/nodejs -Dservice $@" +ags="generate -t modules/openapi-generator/src/main/resources/nodejs -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g nodejs-server-deprecated -o samples/server/petstore/nodejs -Dservice $@" java $JAVA_OPTS -jar $executable $ags diff --git a/docs/generators.md b/docs/generators.md index 3ca62059b7b5..5f890cab5bcc 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -91,7 +91,7 @@ The following generators are available: - [jaxrs-spec](generators/jaxrs-spec.md) - [kotlin-server](generators/kotlin-server.md) - [kotlin-spring](generators/kotlin-spring.md) - - [nodejs-server](generators/nodejs-server.md) + - [nodejs-server-deprecated](generators/nodejs-server-deprecated.md) (deprecated) - [php-laravel](generators/php-laravel.md) - [php-lumen](generators/php-lumen.md) - [php-silex](generators/php-silex.md) diff --git a/samples/server/petstore/nodejs-google-cloud-functions/api/openapi.yaml b/samples/server/petstore/nodejs-google-cloud-functions/api/openapi.yaml index 3a1276ec5f87..f2908efadee3 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/api/openapi.yaml +++ b/samples/server/petstore/nodejs-google-cloud-functions/api/openapi.yaml @@ -1,4 +1,4 @@ -openapi: 3.0.1 +openapi: 3.0.0 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. @@ -7,6 +7,9 @@ info: url: http://www.apache.org/licenses/LICENSE-2.0.html title: OpenAPI Petstore version: 1.0.0 +externalDocs: + description: Find out more about Swagger + url: http://swagger.io servers: - url: http://petstore.swagger.io/v2 tags: @@ -21,18 +24,9 @@ paths: post: operationId: addPet requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - description: Pet object that needs to be added to the store - required: true + $ref: '#/components/requestBodies/Pet' responses: 405: - content: {} description: Invalid input security: - petstore_auth: @@ -41,29 +35,17 @@ paths: summary: Add a new pet to the store tags: - pet - x-codegen-request-body-name: body x-swagger-router-controller: Pet put: operationId: updatePet requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - description: Pet object that needs to be added to the store - required: true + $ref: '#/components/requestBodies/Pet' responses: 400: - content: {} description: Invalid ID supplied 404: - content: {} description: Pet not found 405: - content: {} description: Validation exception security: - petstore_auth: @@ -72,7 +54,6 @@ paths: summary: Update an existing pet tags: - pet - x-codegen-request-body-name: body x-swagger-router-controller: Pet /pet/findByStatus: get: @@ -109,11 +90,9 @@ paths: type: array description: successful operation 400: - content: {} description: Invalid status value security: - petstore_auth: - - write:pets - read:pets summary: Finds Pets by status tags: @@ -136,6 +115,15 @@ paths: type: string type: array style: form + - description: Maximum number of items to return + explode: true + in: query + name: maxCount + required: false + schema: + format: int32 + type: integer + style: form responses: 200: content: @@ -151,11 +139,9 @@ paths: type: array description: successful operation 400: - content: {} description: Invalid tag value security: - petstore_auth: - - write:pets - read:pets summary: Finds Pets by tags tags: @@ -165,20 +151,24 @@ paths: delete: operationId: deletePet parameters: - - in: header + - explode: false + in: header name: api_key + required: false schema: type: string + style: simple - description: Pet id to delete + explode: false in: path name: petId required: true schema: format: int64 type: integer + style: simple responses: 400: - content: {} description: Invalid pet value security: - petstore_auth: @@ -193,12 +183,14 @@ paths: operationId: getPetById parameters: - description: ID of pet to return + explode: false in: path name: petId required: true schema: format: int64 type: integer + style: simple responses: 200: content: @@ -210,10 +202,8 @@ paths: $ref: '#/components/schemas/Pet' description: successful operation 400: - content: {} description: Invalid ID supplied 404: - content: {} description: Pet not found security: - api_key: [] @@ -225,13 +215,16 @@ paths: operationId: updatePetWithForm parameters: - description: ID of pet that needs to be updated + explode: false in: path name: petId required: true schema: format: int64 type: integer + style: simple requestBody: + $ref: '#/components/requestBodies/inline_object' content: application/x-www-form-urlencoded: schema: @@ -242,9 +235,9 @@ paths: status: description: Updated status of the pet type: string + type: object responses: 405: - content: {} description: Invalid input security: - petstore_auth: @@ -259,13 +252,16 @@ paths: operationId: uploadFile parameters: - description: ID of pet to update + explode: false in: path name: petId required: true schema: format: int64 type: integer + style: simple requestBody: + $ref: '#/components/requestBodies/inline_object_1' content: multipart/form-data: schema: @@ -277,6 +273,7 @@ paths: description: file to upload format: binary type: string + type: object responses: 200: content: @@ -317,7 +314,7 @@ paths: operationId: placeOrder requestBody: content: - '*/*': + application/json: schema: $ref: '#/components/schemas/Order' description: order placed for purchasing the pet @@ -333,12 +330,10 @@ paths: $ref: '#/components/schemas/Order' description: successful operation 400: - content: {} description: Invalid Order summary: Place an order for a pet tags: - store - x-codegen-request-body-name: body x-swagger-router-controller: Store /store/order/{orderId}: delete: @@ -347,17 +342,17 @@ paths: operationId: deleteOrder parameters: - description: ID of the order that needs to be deleted + explode: false in: path name: orderId required: true schema: type: string + style: simple responses: 400: - content: {} description: Invalid ID supplied 404: - content: {} description: Order not found summary: Delete purchase order by ID tags: @@ -369,6 +364,7 @@ paths: operationId: getOrderById parameters: - description: ID of pet that needs to be fetched + explode: false in: path name: orderId required: true @@ -377,6 +373,7 @@ paths: maximum: 5 minimum: 1 type: integer + style: simple responses: 200: content: @@ -388,10 +385,8 @@ paths: $ref: '#/components/schemas/Order' description: successful operation 400: - content: {} description: Invalid ID supplied 404: - content: {} description: Order not found summary: Find purchase order by ID tags: @@ -403,78 +398,69 @@ paths: operationId: createUser requestBody: content: - '*/*': + application/json: schema: $ref: '#/components/schemas/User' description: Created user object required: true responses: default: - content: {} description: successful operation + security: + - auth_cookie: [] summary: Create user tags: - user - x-codegen-request-body-name: body x-swagger-router-controller: User /user/createWithArray: post: operationId: createUsersWithArrayInput requestBody: - content: - '*/*': - schema: - items: - $ref: '#/components/schemas/User' - type: array - description: List of user object - required: true + $ref: '#/components/requestBodies/UserArray' responses: default: - content: {} description: successful operation + security: + - auth_cookie: [] summary: Creates list of users with given input array tags: - user - x-codegen-request-body-name: body x-swagger-router-controller: User /user/createWithList: post: operationId: createUsersWithListInput requestBody: - content: - '*/*': - schema: - items: - $ref: '#/components/schemas/User' - type: array - description: List of user object - required: true + $ref: '#/components/requestBodies/UserArray' responses: default: - content: {} description: successful operation + security: + - auth_cookie: [] summary: Creates list of users with given input array tags: - user - x-codegen-request-body-name: body x-swagger-router-controller: User /user/login: get: operationId: loginUser parameters: - description: The user name for login + explode: true in: query name: username required: true schema: + pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$ type: string + style: form - description: The password for login in clear text + explode: true in: query name: password required: true schema: type: string + style: form responses: 200: content: @@ -486,18 +472,29 @@ paths: type: string description: successful operation headers: + Set-Cookie: + description: Cookie authentication key for use with the `auth_cookie` + apiKey authentication. + explode: false + schema: + example: AUTH_KEY=abcde12345; Path=/; HttpOnly + type: string + style: simple X-Rate-Limit: description: calls per hour allowed by the user + explode: false schema: format: int32 type: integer + style: simple X-Expires-After: description: date in UTC when toekn expires + explode: false schema: format: date-time type: string + style: simple 400: - content: {} description: Invalid username/password supplied summary: Logs user into the system tags: @@ -508,8 +505,9 @@ paths: operationId: logoutUser responses: default: - content: {} description: successful operation + security: + - auth_cookie: [] summary: Logs out current logged in user session tags: - user @@ -520,18 +518,20 @@ paths: operationId: deleteUser parameters: - description: The name that needs to be deleted + explode: false in: path name: username required: true schema: type: string + style: simple responses: 400: - content: {} description: Invalid username supplied 404: - content: {} description: User not found + security: + - auth_cookie: [] summary: Delete user tags: - user @@ -540,11 +540,13 @@ paths: operationId: getUserByName parameters: - description: The name that needs to be fetched. Use user1 for testing. + explode: false in: path name: username required: true schema: type: string + style: simple responses: 200: content: @@ -556,10 +558,8 @@ paths: $ref: '#/components/schemas/User' description: successful operation 400: - content: {} description: Invalid username supplied 404: - content: {} description: User not found summary: Get user by user name tags: @@ -570,31 +570,62 @@ paths: operationId: updateUser parameters: - description: name that need to be deleted + explode: false in: path name: username required: true schema: type: string + style: simple requestBody: content: - '*/*': + application/json: schema: $ref: '#/components/schemas/User' description: Updated user object required: true responses: 400: - content: {} description: Invalid user supplied 404: - content: {} description: User not found + security: + - auth_cookie: [] summary: Updated user tags: - user - x-codegen-request-body-name: body x-swagger-router-controller: User components: + requestBodies: + UserArray: + content: + application/json: + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + Pet: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + inline_object: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/inline_object' + inline_object_1: + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/inline_object_1' schemas: Order: description: An order for a pets from the pet store @@ -642,6 +673,7 @@ components: format: int64 type: integer name: + pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$ type: string title: Pet category type: object @@ -767,6 +799,25 @@ components: type: string title: An uploaded response type: object + inline_object: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + type: object + inline_object_1: + 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 +831,7 @@ components: in: header name: api_key type: apiKey + auth_cookie: + in: cookie + name: AUTH_KEY + type: apiKey diff --git a/samples/server/petstore/nodejs-google-cloud-functions/controllers/Pet.js b/samples/server/petstore/nodejs-google-cloud-functions/controllers/Pet.js index f3286ea17349..14a5573b6421 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/controllers/Pet.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/controllers/Pet.js @@ -4,8 +4,8 @@ var utils = require('../utils/writer.js'); var Pet = require('../service/PetService'); module.exports.addPet = function addPet (req, res, next) { - var body = req.swagger.params['body'].value; - Pet.addPet(body) + var pet = req.swagger.params['Pet'].value; + Pet.addPet(pet) .then(function (response) { utils.writeJson(res, response); }) @@ -39,7 +39,8 @@ module.exports.findPetsByStatus = function findPetsByStatus (req, res, next) { module.exports.findPetsByTags = function findPetsByTags (req, res, next) { var tags = req.swagger.params['tags'].value; - Pet.findPetsByTags(tags) + var maxCount = req.swagger.params['maxCount'].value; + Pet.findPetsByTags(tags,maxCount) .then(function (response) { utils.writeJson(res, response); }) @@ -60,8 +61,8 @@ module.exports.getPetById = function getPetById (req, res, next) { }; module.exports.updatePet = function updatePet (req, res, next) { - var body = req.swagger.params['body'].value; - Pet.updatePet(body) + var pet = req.swagger.params['Pet'].value; + Pet.updatePet(pet) .then(function (response) { utils.writeJson(res, response); }) diff --git a/samples/server/petstore/nodejs-google-cloud-functions/controllers/Store.js b/samples/server/petstore/nodejs-google-cloud-functions/controllers/Store.js index b781e64556fd..eb403b6b87dd 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/controllers/Store.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/controllers/Store.js @@ -36,8 +36,8 @@ module.exports.getOrderById = function getOrderById (req, res, next) { }; module.exports.placeOrder = function placeOrder (req, res, next) { - var body = req.swagger.params['body'].value; - Store.placeOrder(body) + var order = req.swagger.params['Order'].value; + Store.placeOrder(order) .then(function (response) { utils.writeJson(res, response); }) diff --git a/samples/server/petstore/nodejs-google-cloud-functions/controllers/User.js b/samples/server/petstore/nodejs-google-cloud-functions/controllers/User.js index f444efa38e58..6a67f0ea212e 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/controllers/User.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/controllers/User.js @@ -4,8 +4,8 @@ var utils = require('../utils/writer.js'); var User = require('../service/UserService'); module.exports.createUser = function createUser (req, res, next) { - var body = req.swagger.params['body'].value; - User.createUser(body) + var user = req.swagger.params['User'].value; + User.createUser(user) .then(function (response) { utils.writeJson(res, response); }) @@ -15,8 +15,8 @@ module.exports.createUser = function createUser (req, res, next) { }; module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (req, res, next) { - var body = req.swagger.params['body'].value; - User.createUsersWithArrayInput(body) + var user = req.swagger.params['User'].value; + User.createUsersWithArrayInput(user) .then(function (response) { utils.writeJson(res, response); }) @@ -26,8 +26,8 @@ module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (r }; module.exports.createUsersWithListInput = function createUsersWithListInput (req, res, next) { - var body = req.swagger.params['body'].value; - User.createUsersWithListInput(body) + var user = req.swagger.params['User'].value; + User.createUsersWithListInput(user) .then(function (response) { utils.writeJson(res, response); }) @@ -82,8 +82,8 @@ module.exports.logoutUser = function logoutUser (req, res, next) { module.exports.updateUser = function updateUser (req, res, next) { var username = req.swagger.params['username'].value; - var body = req.swagger.params['body'].value; - User.updateUser(username,body) + var user = req.swagger.params['User'].value; + User.updateUser(username,user) .then(function (response) { utils.writeJson(res, response); }) diff --git a/samples/server/petstore/nodejs-google-cloud-functions/service/PetService.js b/samples/server/petstore/nodejs-google-cloud-functions/service/PetService.js index 6a276ef1e8cc..441e248b271b 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/service/PetService.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/service/PetService.js @@ -4,10 +4,10 @@ /** * Add a new pet to the store * - * body Pet Pet object that needs to be added to the store + * pet Pet Pet object that needs to be added to the store * no response value expected for this operation **/ -exports.addPet = function(body) { +exports.addPet = function(pet) { return new Promise(function(resolve, reject) { resolve(); }); @@ -69,9 +69,10 @@ exports.findPetsByStatus = function(status) { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * * tags List Tags to filter by + * maxCount Integer Maximum number of items to return (optional) * returns List **/ -exports.findPetsByTags = function(tags) { +exports.findPetsByTags = function(tags,maxCount) { return new Promise(function(resolve, reject) { var examples = {}; examples['application/json'] = { @@ -139,10 +140,10 @@ exports.getPetById = function(petId) { /** * Update an existing pet * - * body Pet Pet object that needs to be added to the store + * pet Pet Pet object that needs to be added to the store * no response value expected for this operation **/ -exports.updatePet = function(body) { +exports.updatePet = function(pet) { return new Promise(function(resolve, reject) { resolve(); }); diff --git a/samples/server/petstore/nodejs-google-cloud-functions/service/StoreService.js b/samples/server/petstore/nodejs-google-cloud-functions/service/StoreService.js index afdbe501622d..50a2768d9051 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/service/StoreService.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/service/StoreService.js @@ -63,10 +63,10 @@ exports.getOrderById = function(orderId) { /** * Place an order for a pet * - * body Order order placed for purchasing the pet + * order Order order placed for purchasing the pet * returns Order **/ -exports.placeOrder = function(body) { +exports.placeOrder = function(order) { return new Promise(function(resolve, reject) { var examples = {}; examples['application/json'] = { diff --git a/samples/server/petstore/nodejs-google-cloud-functions/service/UserService.js b/samples/server/petstore/nodejs-google-cloud-functions/service/UserService.js index 9753092fb905..ae482204a21b 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/service/UserService.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/service/UserService.js @@ -5,10 +5,10 @@ * Create user * This can only be done by the logged in user. * - * body User Created user object + * user User Created user object * no response value expected for this operation **/ -exports.createUser = function(body) { +exports.createUser = function(user) { return new Promise(function(resolve, reject) { resolve(); }); @@ -18,10 +18,10 @@ exports.createUser = function(body) { /** * Creates list of users with given input array * - * body List List of user object + * user List List of user object * no response value expected for this operation **/ -exports.createUsersWithArrayInput = function(body) { +exports.createUsersWithArrayInput = function(user) { return new Promise(function(resolve, reject) { resolve(); }); @@ -31,10 +31,10 @@ exports.createUsersWithArrayInput = function(body) { /** * Creates list of users with given input array * - * body List List of user object + * user List List of user object * no response value expected for this operation **/ -exports.createUsersWithListInput = function(body) { +exports.createUsersWithListInput = function(user) { return new Promise(function(resolve, reject) { resolve(); }); @@ -119,10 +119,10 @@ exports.logoutUser = function() { * This can only be done by the logged in user. * * username String name that need to be deleted - * body User Updated user object + * user User Updated user object * no response value expected for this operation **/ -exports.updateUser = function(username,body) { +exports.updateUser = function(username,user) { return new Promise(function(resolve, reject) { resolve(); }); diff --git a/samples/server/petstore/nodejs/api/openapi.yaml b/samples/server/petstore/nodejs/api/openapi.yaml index 3a1276ec5f87..f2908efadee3 100644 --- a/samples/server/petstore/nodejs/api/openapi.yaml +++ b/samples/server/petstore/nodejs/api/openapi.yaml @@ -1,4 +1,4 @@ -openapi: 3.0.1 +openapi: 3.0.0 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. @@ -7,6 +7,9 @@ info: url: http://www.apache.org/licenses/LICENSE-2.0.html title: OpenAPI Petstore version: 1.0.0 +externalDocs: + description: Find out more about Swagger + url: http://swagger.io servers: - url: http://petstore.swagger.io/v2 tags: @@ -21,18 +24,9 @@ paths: post: operationId: addPet requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - description: Pet object that needs to be added to the store - required: true + $ref: '#/components/requestBodies/Pet' responses: 405: - content: {} description: Invalid input security: - petstore_auth: @@ -41,29 +35,17 @@ paths: summary: Add a new pet to the store tags: - pet - x-codegen-request-body-name: body x-swagger-router-controller: Pet put: operationId: updatePet requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - description: Pet object that needs to be added to the store - required: true + $ref: '#/components/requestBodies/Pet' responses: 400: - content: {} description: Invalid ID supplied 404: - content: {} description: Pet not found 405: - content: {} description: Validation exception security: - petstore_auth: @@ -72,7 +54,6 @@ paths: summary: Update an existing pet tags: - pet - x-codegen-request-body-name: body x-swagger-router-controller: Pet /pet/findByStatus: get: @@ -109,11 +90,9 @@ paths: type: array description: successful operation 400: - content: {} description: Invalid status value security: - petstore_auth: - - write:pets - read:pets summary: Finds Pets by status tags: @@ -136,6 +115,15 @@ paths: type: string type: array style: form + - description: Maximum number of items to return + explode: true + in: query + name: maxCount + required: false + schema: + format: int32 + type: integer + style: form responses: 200: content: @@ -151,11 +139,9 @@ paths: type: array description: successful operation 400: - content: {} description: Invalid tag value security: - petstore_auth: - - write:pets - read:pets summary: Finds Pets by tags tags: @@ -165,20 +151,24 @@ paths: delete: operationId: deletePet parameters: - - in: header + - explode: false + in: header name: api_key + required: false schema: type: string + style: simple - description: Pet id to delete + explode: false in: path name: petId required: true schema: format: int64 type: integer + style: simple responses: 400: - content: {} description: Invalid pet value security: - petstore_auth: @@ -193,12 +183,14 @@ paths: operationId: getPetById parameters: - description: ID of pet to return + explode: false in: path name: petId required: true schema: format: int64 type: integer + style: simple responses: 200: content: @@ -210,10 +202,8 @@ paths: $ref: '#/components/schemas/Pet' description: successful operation 400: - content: {} description: Invalid ID supplied 404: - content: {} description: Pet not found security: - api_key: [] @@ -225,13 +215,16 @@ paths: operationId: updatePetWithForm parameters: - description: ID of pet that needs to be updated + explode: false in: path name: petId required: true schema: format: int64 type: integer + style: simple requestBody: + $ref: '#/components/requestBodies/inline_object' content: application/x-www-form-urlencoded: schema: @@ -242,9 +235,9 @@ paths: status: description: Updated status of the pet type: string + type: object responses: 405: - content: {} description: Invalid input security: - petstore_auth: @@ -259,13 +252,16 @@ paths: operationId: uploadFile parameters: - description: ID of pet to update + explode: false in: path name: petId required: true schema: format: int64 type: integer + style: simple requestBody: + $ref: '#/components/requestBodies/inline_object_1' content: multipart/form-data: schema: @@ -277,6 +273,7 @@ paths: description: file to upload format: binary type: string + type: object responses: 200: content: @@ -317,7 +314,7 @@ paths: operationId: placeOrder requestBody: content: - '*/*': + application/json: schema: $ref: '#/components/schemas/Order' description: order placed for purchasing the pet @@ -333,12 +330,10 @@ paths: $ref: '#/components/schemas/Order' description: successful operation 400: - content: {} description: Invalid Order summary: Place an order for a pet tags: - store - x-codegen-request-body-name: body x-swagger-router-controller: Store /store/order/{orderId}: delete: @@ -347,17 +342,17 @@ paths: operationId: deleteOrder parameters: - description: ID of the order that needs to be deleted + explode: false in: path name: orderId required: true schema: type: string + style: simple responses: 400: - content: {} description: Invalid ID supplied 404: - content: {} description: Order not found summary: Delete purchase order by ID tags: @@ -369,6 +364,7 @@ paths: operationId: getOrderById parameters: - description: ID of pet that needs to be fetched + explode: false in: path name: orderId required: true @@ -377,6 +373,7 @@ paths: maximum: 5 minimum: 1 type: integer + style: simple responses: 200: content: @@ -388,10 +385,8 @@ paths: $ref: '#/components/schemas/Order' description: successful operation 400: - content: {} description: Invalid ID supplied 404: - content: {} description: Order not found summary: Find purchase order by ID tags: @@ -403,78 +398,69 @@ paths: operationId: createUser requestBody: content: - '*/*': + application/json: schema: $ref: '#/components/schemas/User' description: Created user object required: true responses: default: - content: {} description: successful operation + security: + - auth_cookie: [] summary: Create user tags: - user - x-codegen-request-body-name: body x-swagger-router-controller: User /user/createWithArray: post: operationId: createUsersWithArrayInput requestBody: - content: - '*/*': - schema: - items: - $ref: '#/components/schemas/User' - type: array - description: List of user object - required: true + $ref: '#/components/requestBodies/UserArray' responses: default: - content: {} description: successful operation + security: + - auth_cookie: [] summary: Creates list of users with given input array tags: - user - x-codegen-request-body-name: body x-swagger-router-controller: User /user/createWithList: post: operationId: createUsersWithListInput requestBody: - content: - '*/*': - schema: - items: - $ref: '#/components/schemas/User' - type: array - description: List of user object - required: true + $ref: '#/components/requestBodies/UserArray' responses: default: - content: {} description: successful operation + security: + - auth_cookie: [] summary: Creates list of users with given input array tags: - user - x-codegen-request-body-name: body x-swagger-router-controller: User /user/login: get: operationId: loginUser parameters: - description: The user name for login + explode: true in: query name: username required: true schema: + pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$ type: string + style: form - description: The password for login in clear text + explode: true in: query name: password required: true schema: type: string + style: form responses: 200: content: @@ -486,18 +472,29 @@ paths: type: string description: successful operation headers: + Set-Cookie: + description: Cookie authentication key for use with the `auth_cookie` + apiKey authentication. + explode: false + schema: + example: AUTH_KEY=abcde12345; Path=/; HttpOnly + type: string + style: simple X-Rate-Limit: description: calls per hour allowed by the user + explode: false schema: format: int32 type: integer + style: simple X-Expires-After: description: date in UTC when toekn expires + explode: false schema: format: date-time type: string + style: simple 400: - content: {} description: Invalid username/password supplied summary: Logs user into the system tags: @@ -508,8 +505,9 @@ paths: operationId: logoutUser responses: default: - content: {} description: successful operation + security: + - auth_cookie: [] summary: Logs out current logged in user session tags: - user @@ -520,18 +518,20 @@ paths: operationId: deleteUser parameters: - description: The name that needs to be deleted + explode: false in: path name: username required: true schema: type: string + style: simple responses: 400: - content: {} description: Invalid username supplied 404: - content: {} description: User not found + security: + - auth_cookie: [] summary: Delete user tags: - user @@ -540,11 +540,13 @@ paths: operationId: getUserByName parameters: - description: The name that needs to be fetched. Use user1 for testing. + explode: false in: path name: username required: true schema: type: string + style: simple responses: 200: content: @@ -556,10 +558,8 @@ paths: $ref: '#/components/schemas/User' description: successful operation 400: - content: {} description: Invalid username supplied 404: - content: {} description: User not found summary: Get user by user name tags: @@ -570,31 +570,62 @@ paths: operationId: updateUser parameters: - description: name that need to be deleted + explode: false in: path name: username required: true schema: type: string + style: simple requestBody: content: - '*/*': + application/json: schema: $ref: '#/components/schemas/User' description: Updated user object required: true responses: 400: - content: {} description: Invalid user supplied 404: - content: {} description: User not found + security: + - auth_cookie: [] summary: Updated user tags: - user - x-codegen-request-body-name: body x-swagger-router-controller: User components: + requestBodies: + UserArray: + content: + application/json: + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true + Pet: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + inline_object: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/inline_object' + inline_object_1: + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/inline_object_1' schemas: Order: description: An order for a pets from the pet store @@ -642,6 +673,7 @@ components: format: int64 type: integer name: + pattern: ^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$ type: string title: Pet category type: object @@ -767,6 +799,25 @@ components: type: string title: An uploaded response type: object + inline_object: + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + type: object + inline_object_1: + 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 +831,7 @@ components: in: header name: api_key type: apiKey + auth_cookie: + in: cookie + name: AUTH_KEY + type: apiKey diff --git a/samples/server/petstore/nodejs/controllers/Pet.js b/samples/server/petstore/nodejs/controllers/Pet.js index f3286ea17349..14a5573b6421 100644 --- a/samples/server/petstore/nodejs/controllers/Pet.js +++ b/samples/server/petstore/nodejs/controllers/Pet.js @@ -4,8 +4,8 @@ var utils = require('../utils/writer.js'); var Pet = require('../service/PetService'); module.exports.addPet = function addPet (req, res, next) { - var body = req.swagger.params['body'].value; - Pet.addPet(body) + var pet = req.swagger.params['Pet'].value; + Pet.addPet(pet) .then(function (response) { utils.writeJson(res, response); }) @@ -39,7 +39,8 @@ module.exports.findPetsByStatus = function findPetsByStatus (req, res, next) { module.exports.findPetsByTags = function findPetsByTags (req, res, next) { var tags = req.swagger.params['tags'].value; - Pet.findPetsByTags(tags) + var maxCount = req.swagger.params['maxCount'].value; + Pet.findPetsByTags(tags,maxCount) .then(function (response) { utils.writeJson(res, response); }) @@ -60,8 +61,8 @@ module.exports.getPetById = function getPetById (req, res, next) { }; module.exports.updatePet = function updatePet (req, res, next) { - var body = req.swagger.params['body'].value; - Pet.updatePet(body) + var pet = req.swagger.params['Pet'].value; + Pet.updatePet(pet) .then(function (response) { utils.writeJson(res, response); }) diff --git a/samples/server/petstore/nodejs/controllers/Store.js b/samples/server/petstore/nodejs/controllers/Store.js index b781e64556fd..eb403b6b87dd 100644 --- a/samples/server/petstore/nodejs/controllers/Store.js +++ b/samples/server/petstore/nodejs/controllers/Store.js @@ -36,8 +36,8 @@ module.exports.getOrderById = function getOrderById (req, res, next) { }; module.exports.placeOrder = function placeOrder (req, res, next) { - var body = req.swagger.params['body'].value; - Store.placeOrder(body) + var order = req.swagger.params['Order'].value; + Store.placeOrder(order) .then(function (response) { utils.writeJson(res, response); }) diff --git a/samples/server/petstore/nodejs/controllers/User.js b/samples/server/petstore/nodejs/controllers/User.js index f444efa38e58..6a67f0ea212e 100644 --- a/samples/server/petstore/nodejs/controllers/User.js +++ b/samples/server/petstore/nodejs/controllers/User.js @@ -4,8 +4,8 @@ var utils = require('../utils/writer.js'); var User = require('../service/UserService'); module.exports.createUser = function createUser (req, res, next) { - var body = req.swagger.params['body'].value; - User.createUser(body) + var user = req.swagger.params['User'].value; + User.createUser(user) .then(function (response) { utils.writeJson(res, response); }) @@ -15,8 +15,8 @@ module.exports.createUser = function createUser (req, res, next) { }; module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (req, res, next) { - var body = req.swagger.params['body'].value; - User.createUsersWithArrayInput(body) + var user = req.swagger.params['User'].value; + User.createUsersWithArrayInput(user) .then(function (response) { utils.writeJson(res, response); }) @@ -26,8 +26,8 @@ module.exports.createUsersWithArrayInput = function createUsersWithArrayInput (r }; module.exports.createUsersWithListInput = function createUsersWithListInput (req, res, next) { - var body = req.swagger.params['body'].value; - User.createUsersWithListInput(body) + var user = req.swagger.params['User'].value; + User.createUsersWithListInput(user) .then(function (response) { utils.writeJson(res, response); }) @@ -82,8 +82,8 @@ module.exports.logoutUser = function logoutUser (req, res, next) { module.exports.updateUser = function updateUser (req, res, next) { var username = req.swagger.params['username'].value; - var body = req.swagger.params['body'].value; - User.updateUser(username,body) + var user = req.swagger.params['User'].value; + User.updateUser(username,user) .then(function (response) { utils.writeJson(res, response); }) diff --git a/samples/server/petstore/nodejs/service/PetService.js b/samples/server/petstore/nodejs/service/PetService.js index 6a276ef1e8cc..441e248b271b 100644 --- a/samples/server/petstore/nodejs/service/PetService.js +++ b/samples/server/petstore/nodejs/service/PetService.js @@ -4,10 +4,10 @@ /** * Add a new pet to the store * - * body Pet Pet object that needs to be added to the store + * pet Pet Pet object that needs to be added to the store * no response value expected for this operation **/ -exports.addPet = function(body) { +exports.addPet = function(pet) { return new Promise(function(resolve, reject) { resolve(); }); @@ -69,9 +69,10 @@ exports.findPetsByStatus = function(status) { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * * tags List Tags to filter by + * maxCount Integer Maximum number of items to return (optional) * returns List **/ -exports.findPetsByTags = function(tags) { +exports.findPetsByTags = function(tags,maxCount) { return new Promise(function(resolve, reject) { var examples = {}; examples['application/json'] = { @@ -139,10 +140,10 @@ exports.getPetById = function(petId) { /** * Update an existing pet * - * body Pet Pet object that needs to be added to the store + * pet Pet Pet object that needs to be added to the store * no response value expected for this operation **/ -exports.updatePet = function(body) { +exports.updatePet = function(pet) { return new Promise(function(resolve, reject) { resolve(); }); diff --git a/samples/server/petstore/nodejs/service/StoreService.js b/samples/server/petstore/nodejs/service/StoreService.js index afdbe501622d..50a2768d9051 100644 --- a/samples/server/petstore/nodejs/service/StoreService.js +++ b/samples/server/petstore/nodejs/service/StoreService.js @@ -63,10 +63,10 @@ exports.getOrderById = function(orderId) { /** * Place an order for a pet * - * body Order order placed for purchasing the pet + * order Order order placed for purchasing the pet * returns Order **/ -exports.placeOrder = function(body) { +exports.placeOrder = function(order) { return new Promise(function(resolve, reject) { var examples = {}; examples['application/json'] = { diff --git a/samples/server/petstore/nodejs/service/UserService.js b/samples/server/petstore/nodejs/service/UserService.js index 9753092fb905..ae482204a21b 100644 --- a/samples/server/petstore/nodejs/service/UserService.js +++ b/samples/server/petstore/nodejs/service/UserService.js @@ -5,10 +5,10 @@ * Create user * This can only be done by the logged in user. * - * body User Created user object + * user User Created user object * no response value expected for this operation **/ -exports.createUser = function(body) { +exports.createUser = function(user) { return new Promise(function(resolve, reject) { resolve(); }); @@ -18,10 +18,10 @@ exports.createUser = function(body) { /** * Creates list of users with given input array * - * body List List of user object + * user List List of user object * no response value expected for this operation **/ -exports.createUsersWithArrayInput = function(body) { +exports.createUsersWithArrayInput = function(user) { return new Promise(function(resolve, reject) { resolve(); }); @@ -31,10 +31,10 @@ exports.createUsersWithArrayInput = function(body) { /** * Creates list of users with given input array * - * body List List of user object + * user List List of user object * no response value expected for this operation **/ -exports.createUsersWithListInput = function(body) { +exports.createUsersWithListInput = function(user) { return new Promise(function(resolve, reject) { resolve(); }); @@ -119,10 +119,10 @@ exports.logoutUser = function() { * This can only be done by the logged in user. * * username String name that need to be deleted - * body User Updated user object + * user User Updated user object * no response value expected for this operation **/ -exports.updateUser = function(username,body) { +exports.updateUser = function(username,user) { return new Promise(function(resolve, reject) { resolve(); }); From 660732c40b50db7f8191ccbae354ceda05d59de1 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 4 Jun 2019 17:02:15 +0800 Subject: [PATCH 3/3] add new file --- docs/generators/nodejs-server-deprecated.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 docs/generators/nodejs-server-deprecated.md diff --git a/docs/generators/nodejs-server-deprecated.md b/docs/generators/nodejs-server-deprecated.md new file mode 100644 index 000000000000..c8741e58f4cb --- /dev/null +++ b/docs/generators/nodejs-server-deprecated.md @@ -0,0 +1,16 @@ + +--- +id: generator-opts-server-nodejs-server-deprecated +title: Config Options for nodejs-server-deprecated +sidebar_label: nodejs-server-deprecated +--- + +| Option | Description | Values | Default | +| ------ | ----------- | ------ | ------- | +|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| +|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| +|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| +|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false| +|googleCloudFunctions|When specified, it will generate the code which runs within Google Cloud Functions instead of standalone Node.JS server. See https://cloud.google.com/functions/docs/quickstart for the details of how to deploy the generated code.| |false| +|exportedName|When the generated code will be deployed to Google Cloud Functions, this option can be used to update the name of the exported function. By default, it refers to the basePath. This does not affect normal standalone nodejs server code.| |null| +|serverPort|TCP port to listen on.| |null|