encode / apistar

The Web API toolkit. 🛠
https://docs.apistar.com
BSD 3-Clause "New" or "Revised" License
5.57k stars 411 forks source link

Swagger execute does not show responses because missing response section in schema #596

Closed mnebuerquo closed 5 years ago

mnebuerquo commented 6 years ago

Maybe this is a documentation issue, or maybe it's something I'm missing. I created a sample api, and was trying out the swagger with it. It seems to work nicely except I'm not getting the responses to show up in the swagger page. I think this is because there isn't a responses section in the schema for each api endpoint.

Here's a link to my example api: https://github.com/mnebuerquo/apistar-example

To see it in action, just git clone, then docker-compose up. There are links in the readme for the pages you can test.

Here is one of my route handlers:

routes = [
    Route('/game/{gameid}', method='GET', handler=gameGetState),
]

def gameGetState(gameid: str) -> dict:
    return {'status': 'in-progress'}

The swagger shows the argument gameid as a string, thanks to the annotation. The response should be indicated with the dict argument, but it does not generate anything in the responses section in the schema.

songww commented 6 years ago

You should hint return value as subclass of aptstar.types.Type. schema can handle that, but it still not renderred correctly for docs page.

@tomchristie

tomchristie commented 5 years ago

Closing this off given that 0.6 is moving to a framework-agnostic suite of API tools, and will no longer include the server. See https://discuss.apistar.org/t/api-star-as-a-framework-independant-tool/614 and #624.