Open xgqfrms opened 6 years ago
bug
Error initializing middleware
Error: Swagger document(s) failed validation so the server cannot start
solution
$ cd ./api/swagger && swagger validate swagger.yaml
https://stackoverflow.com/questions/37435400/not-a-valid-parameter-definition-swagger-json
http://23.22.16.221/v2/schema.json#
https://npmdoc.github.io/node-npmdoc-swagger-tools/build/apidoc.html
-
& yaml bugmissing
-
symbol bug
http://localhost:8080/users?user=xgqfrms
{
"message": "Cannot read property 'value' of undefined"
}
http://localhost:8080/users?name=xgqfrms
{
"message": "Cannot read property 'value' of undefined"
}
http://127.0.0.1:8080/hello?name=xgqfrms
{
"message": "Hello, xgqfrms!"
}
object
undefined ??? in-valid
why ???
modify config
default.yaml
validateResponse: false
# swagger configuration file
# values in the swagger hash are system configuration for swagger-node
swagger:
fittingsDirs: [ api/fittings ]
defaultPipe: null
swaggerControllerPipe: swagger_controllers # defines the standard processing pipe for controllers
# values defined in the bagpipes key are the bagpipes pipes and fittings definitions
# (see https://github.com/apigee-127/bagpipes)
bagpipes:
_router:
name: swagger_router
mockMode: false
mockControllersDirs: [api/mocks]
controllersDirs: [api/controllers]
_swagger_validate:
name: swagger_validator
validateResponse: false
# validateResponse: true
# pipe for all swagger-node controllers
swagger_controllers:
- onError: json_error_handler
- cors
- swagger_security
- _swagger_validate
- express_compatibility
- _router
# pipe to serve swagger (endpoint is in swagger.yaml)
swagger_raw:
name: swagger_raw
# any other values in this file are just loaded into the config for application access...
// http://localhost:8080/users?user=xgqfrms
{
"users": "Hello, xgqfrms!"
}
// http://localhost:8080/users?name=xgqfrms
{
"users": "Hello, stranger!"
}
swagger & api & swagger ui
https://www.cnblogs.com/xgqfrms/p/9808520.html