GREsau / okapi

OpenAPI (AKA Swagger) document generation for Rust projects
MIT License
606 stars 110 forks source link

is it only tags supported for openapi micro #100

Closed jiangxiaoqiang closed 2 years ago

jiangxiaoqiang commented 2 years ago

I am now integrete the okapi into my project, it seems only tags are supported. Is it possible to use other comment in the okapi? like summary\title........, I can comment the whole api collection right now , but how to comment the single rest api? I have read the source and did not figure out how to do api comment.

ralpha commented 2 years ago

Okapi uses Doc comments to fill in additional info.

So the "Get all users ..." will be used in the final documentation. https://github.com/GREsau/okapi/blob/65244f0037a4625f22a64cc45ef8179cdb984745/examples/json-web-api/src/main.rs#L22-L33

Same with Structs/Enum that are used in arguments and result type. https://github.com/GREsau/okapi/blob/65244f0037a4625f22a64cc45ef8179cdb984745/examples/json-web-api/src/main.rs#L74-L82

You can also provide example data like this: https://github.com/GREsau/okapi/blob/65244f0037a4625f22a64cc45ef8179cdb984745/examples/json-web-api/src/main.rs#L14-L20

This example might also be a good example to take a look at: https://github.com/GREsau/okapi/tree/master/examples/custom_schema

It also shows how, if you really want, you can add all the info you want that the library does not have macros for. But most people don't use this because it is fairly overkill. (see custom_openapi_spec() in main.rs)