diff --git a/bin/nodejs-petstore-google-cloud-functions.sh b/bin/nodejs-petstore-google-cloud-functions.sh index 80e12027058..bfb02d960dc 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 2dfc8f327c7..fbbed3e46f1 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/bin/openapi3/nodejs-petstore-google-cloud-functions.sh b/bin/openapi3/nodejs-petstore-google-cloud-functions.sh index a11e8da6c5d..00ab32fb9ab 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 df83e4ebfa6..a987aced357 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 3ca62059b7b..5f890cab5bc 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/docs/generators/nodejs-server-deprecated.md b/docs/generators/nodejs-server-deprecated.md new file mode 100644 index 00000000000..c8741e58f4c --- /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| 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 896f0837e57..eccb5a0cb3a 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.Paths; 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 class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig */ @Override public String getName() { - return "nodejs-server"; + return "nodejs-server-deprecated"; } /** @@ -153,7 +160,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig */ @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 class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig 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 096bf47efe3..d96260ba335 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 8a31b8d5b86..f2908efadee 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/api/openapi.yaml +++ b/samples/server/petstore/nodejs-google-cloud-functions/api/openapi.yaml @@ -1,178 +1,198 @@ -openapi: 3.0.1 +openapi: 3.0.0 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 +externalDocs: + description: Find out more about Swagger + url: http://swagger.io 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 - requestBody: - description: Pet object that needs to be added to the store - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - required: true - responses: - 400: - description: Invalid ID supplied - content: {} - 404: - description: Pet not found - content: {} - 405: - description: Validation exception - content: {} - security: - - petstore_auth: - - write:pets - - read:pets - x-openapi-router-controller: Pet post: - tags: - - pet - summary: Add a new pet to the store operationId: addPet requestBody: - description: Pet object that needs to be added to the store - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - required: true + $ref: '#/components/requestBodies/Pet' responses: 405: description: Invalid input - content: {} security: - petstore_auth: - write:pets - read:pets - x-openapi-router-controller: Pet - /pet/findByStatus: - get: + summary: Add a new pet to the store tags: - pet - summary: Finds Pets by status + x-swagger-router-controller: Pet + put: + operationId: updatePet + requestBody: + $ref: '#/components/requestBodies/Pet' + responses: + 400: + description: Invalid ID supplied + 404: + description: Pet not found + 405: + description: Validation exception + security: + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + x-swagger-router-controller: Pet + /pet/findByStatus: + get: description: Multiple status values can be provided with comma separated strings operationId: findPetsByStatus parameters: - - name: status - in: query - description: Status values that need to be considered for filter - required: true + - description: Status values that need to be considered for filter explode: false + in: query + name: status + required: true 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: {} 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 - in: query - description: Tags to filter by - required: true + - description: Tags to filter by explode: false + in: query + name: tags + required: true schema: - type: array items: 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: - 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 + security: + - petstore_auth: + - read:pets + summary: Finds Pets by tags + tags: + - pet + x-swagger-router-controller: Pet + /pet/{petId}: + delete: + operationId: deletePet + parameters: + - 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: + description: Invalid pet value security: - petstore_auth: - write:pets - read:pets - x-openapi-router-controller: Pet - /pet/{petId}: - get: + 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 + explode: false in: path - description: ID of pet to return + name: petId required: true schema: - type: integer format: int64 + type: integer + style: simple responses: 200: - description: successful operation content: application/xml: schema: @@ -180,148 +200,127 @@ paths: application/json: schema: $ref: '#/components/schemas/Pet' + description: successful operation 400: description: Invalid ID supplied - content: {} 404: description: Pet not found - content: {} 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 + explode: false in: path - description: ID of pet that needs to be updated + name: petId required: true schema: - type: integer format: int64 + type: integer + style: simple requestBody: + $ref: '#/components/requestBodies/inline_object' 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 + type: object responses: 405: description: Invalid input - content: {} 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 + explode: false in: path - description: ID of pet to update + name: petId required: true schema: - type: integer format: int64 + type: integer + style: simple requestBody: + $ref: '#/components/requestBodies/inline_object_1' 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 + type: object 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: - '*/*': + application/json: 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 +328,54 @@ paths: application/json: schema: $ref: '#/components/schemas/Order' + description: successful operation 400: description: Invalid Order - content: {} - x-openapi-router-controller: Store - /store/order/{orderId}: - get: + summary: Place an order for a pet 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 - operationId: getOrderById + 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 + operationId: deleteOrder parameters: - - name: orderId + - description: ID of the order that needs to be deleted + explode: false in: path - description: ID of pet that needs to be fetched + name: orderId required: true schema: + type: string + style: simple + responses: + 400: + description: Invalid ID supplied + 404: + description: Order not found + summary: Delete purchase order by ID + tags: + - store + 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: + - description: ID of pet that needs to be fetched + explode: false + in: path + name: orderId + required: true + schema: + format: int64 maximum: 5 minimum: 1 type: integer - format: int64 + style: simple responses: 200: - description: successful operation content: application/xml: schema: @@ -360,126 +383,86 @@ paths: application/json: schema: $ref: '#/components/schemas/Order' + description: successful operation 400: description: Invalid ID supplied - content: {} 404: description: Order not found - content: {} - x-openapi-router-controller: Store - delete: + 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: - '*/*': + application/json: schema: $ref: '#/components/schemas/User' + description: Created user object required: true responses: default: description: successful operation - content: {} - x-openapi-router-controller: User + security: + - auth_cookie: [] + summary: Create user + tags: + - user + x-swagger-router-controller: User /user/createWithArray: post: - tags: - - user - summary: Creates list of users with given input array operationId: createUsersWithArrayInput requestBody: - description: List of user object - content: - '*/*': - schema: - type: array - items: - $ref: '#/components/schemas/User' - required: true + $ref: '#/components/requestBodies/UserArray' responses: default: description: successful operation - content: {} - x-openapi-router-controller: User + security: + - auth_cookie: [] + summary: Creates list of users with given input array + tags: + - user + x-swagger-router-controller: User /user/createWithList: post: - tags: - - user - summary: Creates list of users with given input array operationId: createUsersWithListInput requestBody: - description: List of user object - content: - '*/*': - schema: - type: array - items: - $ref: '#/components/schemas/User' - required: true + $ref: '#/components/requestBodies/UserArray' responses: default: description: successful operation - content: {} - x-openapi-router-controller: User - /user/login: - get: + security: + - auth_cookie: [] + summary: Creates list of users with given input array tags: - user - summary: Logs user into the system + x-swagger-router-controller: User + /user/login: + get: operationId: loginUser parameters: - - name: username + - description: The user name for login + explode: true in: query - description: The user name for login - required: true - schema: - type: string - - name: password - in: query - description: The password for login in clear text + 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: - description: successful operation - headers: - X-Rate-Limit: - description: calls per hour allowed by the user - schema: - type: integer - format: int32 - X-Expires-After: - description: date in UTC when toekn expires - schema: - type: string - format: date-time content: application/xml: schema: @@ -487,37 +470,85 @@ paths: application/json: schema: 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: description: Invalid username/password supplied - content: {} - x-openapi-router-controller: User - /user/logout: - get: + 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 - /user/{username}: - get: + security: + - auth_cookie: [] + summary: Logs out current logged in user session tags: - user - summary: Get user by user name - operationId: getUserByName + x-swagger-router-controller: User + /user/{username}: + delete: + description: This can only be done by the logged in user. + operationId: deleteUser parameters: - - name: username + - description: The name that needs to be deleted + explode: false in: path - description: The name that needs to be fetched. Use user1 for testing. + name: username required: true schema: type: string + style: simple + responses: + 400: + description: Invalid username supplied + 404: + description: User not found + security: + - auth_cookie: [] + summary: Delete user + tags: + - user + x-swagger-router-controller: User + get: + 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: - description: successful operation content: application/xml: schema: @@ -525,90 +556,78 @@ paths: application/json: schema: $ref: '#/components/schemas/User' + description: successful operation 400: description: Invalid username supplied - content: {} 404: description: User not found - content: {} - x-openapi-router-controller: User - put: + 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 + explode: false in: path - description: name that need to be deleted + name: username required: true schema: type: string + style: simple requestBody: - description: Updated user object content: - '*/*': + application/json: schema: $ref: '#/components/schemas/User' + description: Updated user object required: true responses: 400: description: Invalid user supplied - content: {} 404: description: User not found - content: {} - x-openapi-router-controller: User - delete: + security: + - auth_cookie: [] + 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-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: - title: Pet Order - type: object - properties: - id: - type: integer - format: int64 - petId: - type: integer - format: int64 - quantity: - type: integer - format: int32 - shipDate: - type: string - format: date-time - status: - type: string - description: Order Status - enum: - - placed - - approved - - delivered - complete: - type: boolean - default: false description: An order for a pets from the pet store example: petId: 6 @@ -617,30 +636,64 @@ components: shipDate: 2000-01-23T04:56:07.000+00:00 complete: false status: placed + properties: + id: + format: int64 + type: integer + petId: + format: int64 + type: integer + quantity: + format: int32 + type: integer + shipDate: + format: date-time + type: string + status: + description: Order Status + enum: + - placed + - approved + - delivered + type: string + complete: + default: false + type: boolean + title: Pet Order + type: object xml: name: Order Category: - title: Pet category - type: object - properties: - id: - type: integer - format: int64 - name: - type: string description: A category for a pet example: name: name id: 6 + properties: + id: + 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 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,72 +707,29 @@ 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 - properties: - id: - type: integer - format: int64 - name: - type: string description: A tag for a pet example: name: name id: 1 + properties: + id: + format: int64 + type: integer + name: + type: string + title: Pet Tag + type: object xml: name: Tag Pet: - title: a Pet - required: - - name - - photoUrls - type: object - properties: - id: - type: integer - format: int64 - category: - $ref: '#/components/schemas/Category' - name: - type: string - example: doggie - photoUrls: - type: array - xml: - name: photoUrl - wrapped: true - items: - type: string - tags: - 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: @@ -736,34 +746,92 @@ components: - name: name id: 1 status: available + properties: + id: + format: int64 + type: integer + category: + $ref: '#/components/schemas/Category' + name: + example: doggie + type: string + photoUrls: + items: + type: string + type: array + xml: + name: photoUrl + wrapped: true + tags: + items: + $ref: '#/components/schemas/Tag' + type: array + xml: + name: tag + wrapped: true + status: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + required: + - name + - photoUrls + title: a Pet + type: object xml: name: Pet ApiResponse: - title: An uploaded response - type: object - properties: - code: - type: integer - format: int32 - type: - type: string - message: - type: string description: Describes the result of uploading an image resource example: code: 0 type: type message: message + properties: + code: + format: int32 + type: integer + type: + type: string + message: + 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: - 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 + 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 53d029ce27c..14a5573b642 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/controllers/Pet.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/controllers/Pet.js @@ -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); }) @@ -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); }) 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 e4a0219ab80..441e248b271 100644 --- a/samples/server/petstore/nodejs-google-cloud-functions/service/PetService.js +++ b/samples/server/petstore/nodejs-google-cloud-functions/service/PetService.js @@ -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(); }); @@ -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'] = { diff --git a/samples/server/petstore/nodejs/.openapi-generator/VERSION b/samples/server/petstore/nodejs/.openapi-generator/VERSION index 0628777500b..d96260ba335 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 877989080ca..f2908efadee 100644 --- a/samples/server/petstore/nodejs/api/openapi.yaml +++ b/samples/server/petstore/nodejs/api/openapi.yaml @@ -1,11 +1,15 @@ -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. + 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 +externalDocs: + description: Find out more about Swagger + url: http://swagger.io servers: - url: http://petstore.swagger.io/v2 tags: @@ -20,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: @@ -44,24 +39,13 @@ paths: 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: @@ -106,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: @@ -119,7 +101,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 @@ -132,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: @@ -147,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: @@ -161,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: @@ -189,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: @@ -206,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: [] @@ -221,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: @@ -238,9 +235,9 @@ paths: status: description: Updated status of the pet type: string + type: object responses: 405: - content: {} description: Invalid input security: - petstore_auth: @@ -255,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: @@ -273,6 +273,7 @@ paths: description: file to upload format: binary type: string + type: object responses: 200: content: @@ -313,7 +314,7 @@ paths: operationId: placeOrder requestBody: content: - '*/*': + application/json: schema: $ref: '#/components/schemas/Order' description: order placed for purchasing the pet @@ -329,7 +330,6 @@ paths: $ref: '#/components/schemas/Order' description: successful operation 400: - content: {} description: Invalid Order summary: Place an order for a pet tags: @@ -337,31 +337,34 @@ paths: 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 + 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: - 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 + explode: false in: path name: orderId required: true @@ -370,6 +373,7 @@ paths: maximum: 5 minimum: 1 type: integer + style: simple responses: 200: content: @@ -381,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: @@ -396,15 +398,16 @@ 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 @@ -413,18 +416,12 @@ paths: 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 @@ -433,18 +430,12 @@ paths: 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 @@ -454,17 +445,22 @@ paths: 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: @@ -476,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: @@ -498,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 @@ -510,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 @@ -530,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: @@ -546,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: @@ -560,30 +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-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 @@ -631,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 @@ -756,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: @@ -769,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 53d029ce27c..14a5573b642 100644 --- a/samples/server/petstore/nodejs/controllers/Pet.js +++ b/samples/server/petstore/nodejs/controllers/Pet.js @@ -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); }) @@ -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); }) diff --git a/samples/server/petstore/nodejs/service/PetService.js b/samples/server/petstore/nodejs/service/PetService.js index e4a0219ab80..441e248b271 100644 --- a/samples/server/petstore/nodejs/service/PetService.js +++ b/samples/server/petstore/nodejs/service/PetService.js @@ -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(); }); @@ -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'] = {