-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
populating swagger description from schema docstring #76
Comments
Hi, Yes, we should use that. There is already support for it in schema-tools (https://github.com/metosin/schema-tools/blob/master/src/schema_tools/core.cljc#L246-L255), but ring-swagger doesn't use that yet. Would you like to integrate that in? |
Sure would like to give it a shot. Which function should I look at in On Tue, Dec 1, 2015 at 8:38 PM, Tommi Reiman [email protected]
|
Hi, (defmacro defschema
"Same as `s/defschema` but adds docstring as swagger's schema description"
[name docstring form]
`(s/defschema ~name ~(str docstring)
(vary-meta ~form assoc-in [:json-schema :description] ~docstring))) |
I think this is possible, if not a little awkward: (s/defschema PhoneRecord
(rsjs/describe
{:phone (rsjs/describe s/Str "The phone number")
(s/optional-key :label) (rsjs/describe s/Str "An optional label")}
"Contact phone record"
:example {:phone "555-1212" :label "Mobile"})) generates: "PhoneRecord" : {
"description" : "Contact phone number",
"example" : {
"phone" : "555-1212",
"label" : "Mobile"
},
"type" : "object",
"properties" : {
"phone" : {
"description" : "The phone number",
"type" : "string"
},
"label" : {
"description" : "An optional label",
"type" : "string"
}
},
"additionalProperties" : false,
"required" : [ "phone" ]
} |
Hi,
I have defined my schemas using defschema and have given them docstrings. When generating the swagger json, I dont see the docstring being extracted.
The swagger spec provides a :description key, is it possible to populate that key using the docstring for a given schema ?
Thanks,
Murtaza
The text was updated successfully, but these errors were encountered: