Thursday, October 13, 2016

First Swagger

Start by editing sample or own simple one

http://editor.swagger.io/

Generate client or server code online in editor or get more customizable package by online generator

curl -X POST -H "content-type:application/json" -d '{"options": {"packageName": "rira_api"},"swaggerUrl":"https://raw.githubusercontent.com/omidmt/rira/0.7.x/api/swagger-api.yaml"}' http://generator.swagger.io/api/gen/clients/python

Response:

{"code":"55b0eb81-87ba-48ff-91f5-3a4444a95462","link":"https://generator.swagger.io/api/gen/download/55b0eb81-87ba-48ff-91f5-3a4444a95462

Sample security definition by 2 ways of using it for client (query/header)

securityDefinitions:
  apikeyHeader:
    type: apiKey
    name: apiKey
    in: header
  apikeyQuery:
    type: apiKey
    name: apiKey
    in: query
security:
  - apikeyHeader: []
  - apikeyQuery: []

[] means apply to all operations, but different definition can be applied per path/operation as well.

Enabe debug mode:
rira_api.configuration.debug = True

No comments: