This repository is currently being migrated. It's locked while the migration is in progress.
Add support for specific docs for each method of an endpoint #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a quick take on #30
This pull request allows to specify different documentation for each method of the same endpoint without breaking the current syntax.
Here's a working example where both the current (
/current_styleendpoint) and the proposed (/userendpoint) syntax are used at the same time:And here's the resulting json:
{ "definitions": { "Address": { "properties": { "country": { "type": "string" }, "postalcode": { "type": "string" }, "state": { "type": "string" }, "street": { "type": "string" } } }, "Group": { "properties": { "name": { "description": "the group's name", "type": "string" } } }, "User": { "properties": { "age": { "description": "the user's age", "type": "integer" }, "name": { "description": "the user's name", "type": "string" } }, "required": [ "email", "name" ] } }, "info": { "title": "Cool product name", "version": "0.0.0" }, "paths": { "/current_style": { "get": { "description": "", "parameters": [ { "in": "body", "name": "body", "schema": { "$ref": "#/definitions/User" } } ], "responses": { "201": { "description": "User created" } }, "summary": "Create a new user", "tags": [ "users" ] } }, "/user": { "get": { "description": "Use this endpoint to get a user object", "responses": { "200": { "description": "user obtained", "schema": { "$ref": "#/definitions/User" } } }, "summary": "Get a user", "tags": [ "User API" ] }, "put": { "description": "Use this endpoint to update a user", "parameters": [ { "in": "formData", "name": "name", "required": true, "type": "string" }, { "in": "formData", "name": "age", "required": true, "type": "integer" } ], "responses": { "202": { "description": "user updated", "schema": { "$ref": "#/definitions/User" } } }, "summary": "Update an user", "tags": [ "User API" ] } } }, "swagger": "2.0" }I am currently using this on our production project at work, although I'm aware it is pretty dirty.
Please criticize as needed.