Skip to content

Instantly share code, notes, and snippets.

@e1senh0rn
Last active December 24, 2015 01:09
Show Gist options
  • Save e1senh0rn/6721242 to your computer and use it in GitHub Desktop.
Save e1senh0rn/6721242 to your computer and use it in GitHub Desktop.

I'm using static documentation with swagger-ui.

Having dist folder from swagger-ui, I have added folder "/docs" and changed in index.html url: "/docs/index.json".

I'm running it via python -m SimpleHTTPServer on port 8000 by default.

Without specifying 'basePath' as full url in resource listing swagger tries to load http://localhost/docs/mobile/version.json without respecting port. Setting basePath to http://localhost:8000/docs helps, but API documentation could be running on any port.

Because of this setting relative paths is much more preferred solution.

{
"apiVersion": "0.1",
"swaggerVersion": "1.2",
"basePath": "/docs",
"apis": [
{
"path": "/mobile/version.json",
"description": "Mobile checks"
}
]
}
{
"apiVersion": "0.1",
"swaggerVersion": "1.2",
"basePath": "http://hello.com",
"produces": [
"application/json"
],
"apis": [
{
"path": "/mobile/version.json",
"operations": [
{
"method": "POST",
"summary": "Checks validity of client version",
"nickname": "mobileVersion",
"type": "container",
"parameters": [
{
"name": "platform",
"description": "Mobile platform",
"required": true,
"allowMultiple": false,
"paramType": "body",
"dataType": "string",
"enum": [
"ios",
"android"
]
},
{
"name": "version",
"description": "API version mobile client supports",
"required": true,
"allowMultiple": false,
"paramType": "body",
"dataType": "string"
}
],
"responseMessages": [
{
"code": 405,
"message": "Invalid input"
}
]
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment