xgqfrms / swagger-api

👋 swagger-api for node.js & react
2 stars 0 forks source link

swagger & api & swagger ui #5

Open xgqfrms opened 6 years ago

xgqfrms commented 6 years ago

swagger & api & swagger ui

https://www.cnblogs.com/xgqfrms/p/9808520.html

xgqfrms commented 6 years ago

error

bug


Error initializing middleware
Error: Swagger document(s) failed validation so the server cannot start

https://github.com/swagger-api/swagger-node/issues/354

xgqfrms commented 6 years ago

solution

solution


$ cd ./api/swagger && swagger validate swagger.yaml

image


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

xgqfrms commented 6 years ago

- & yaml bug

missing - symbol bug

image

xgqfrms commented 6 years ago

Error

image

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"
}

OK

image

http://127.0.0.1:8080/hello?name=xgqfrms


{
    "message": "Hello, xgqfrms!"
}
xgqfrms commented 6 years ago

https://swagger.io/ https://swagger.io/solutions/api-documentation/

http://swagger.io/v2/schema.json https://swagger.io/v2/schema.json

xgqfrms commented 6 years ago

OK

object

image

Error

undefined ??? in-valid

image

xgqfrms commented 6 years ago

image image

image

Error: Response validation failed: failed schema validation

https://github.com/swagger-api

xgqfrms commented 6 years ago

https://github.com/swagger-api/swagger-js https://github.com/swagger-api/swagger-samples

https://github.com/swagger-api/swagger-node

xgqfrms commented 6 years ago

bug ???

https://github.com/swagger-api/swagger-node/issues/578

xgqfrms commented 6 years ago

solution

why ???

image

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...
xgqfrms commented 6 years ago

// http://localhost:8080/users?user=xgqfrms

{
    "users": "Hello, xgqfrms!"
}

// http://localhost:8080/users?name=xgqfrms

{
    "users": "Hello, stranger!"
}