Mark nodejs-server as deprecated (#3083)

* mark nodejs-server as deprecated

* update opeanpi3 script

* add new file
This commit is contained in:
William Cheng 2019-06-04 21:38:28 +08:00 committed by GitHub
parent 89d0c01764
commit c6207c0a49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 641 additions and 478 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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|

View File

@ -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")

View File

@ -1 +1 @@
3.0.0-SNAPSHOT
4.0.2-SNAPSHOT

View File

@ -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);
})

View File

@ -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'] = {

View File

@ -1 +1 @@
3.1.0-SNAPSHOT
4.0.2-SNAPSHOT

View File

@ -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

View File

@ -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);
})

View File

@ -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'] = {