Generate Swagger spec from persistent and serial classes
Recently I needed to generate a Swagger spec from persistent and serial classes, so I'm publishing my code (it's not complete - you still need to hash out the application specifics, but it's a start). It's available here.
Let's say you have these classes:
You can automatically generate this Swagger definition from them:
REST.Test.Person:
type: "object"
properties:
Age:
type: "integer"
DOB:
type: "string"
FavoriteColors:
type: "array"
items:
type: "string"
FavoriteNumbers:
type: "object"
Home:
$ref: "#/definitions/REST.Test.Address"
Name:
type: "string"
Office:
$ref: "#/definitions/REST.Test.Address"
SSN:
type: "string"
Spouse:
$ref: "#/definitions/REST.Test.Person"
REST.Test.Address:
type: "object"
properties:
City:
type: "string"
State:
type: "string"
Street:
type: "string"
Zip:
type: "string"
Main method: Utils.YAML:GenerateClasses
Test run: do ##class(Utils.YAML).Test()
Hi Eduard.
Awesome job, congratulations!
Is there something similar but for REST Dispatcher classes?
Can you elaborate a bit?
What dispatcher class do you want generated?
Sure! Let's say I have this dispatcher class:
Is there a way to generate a YAML documentation for the endpoint /pets/:id, HTTP DELETE method, like you did for REST.Test.Person class?
Sure:
Hmm... interesting... I think I didn't know that class beacuse I still didn't move to IRIS...
Thank you Eduard.
FYI, we're looking to add automatic OpenAPI generation to https://github.com/intersystems/apps-rest at some point in the reasonably-near future. (We had an intern work on it over the summer, and are just kicking the tires on it a bit on our own REST models/APIs before unleashing it on the world.)
Thank you Timothy for let me know.
Don't know if that can help, but with this module, you can do the other way around from swagger generate persitent classes.
https://openexchange.intersystems.com/package/objectscript-openapi-defin...
Hi Guillaume.
One more cool feature to explore when my company moves to IRIS. :)
Thank you for let me know.
💡 This article is considered as InterSystems Data Platform Best Practice.
I am looking to try and generate a swagger spec from a persistent class. The link to the above mentioned code is not working. Could you repost the link or add the code to generate the spec?
Thanks Dan
Have a look at this article/openexchange example :
https://community.intersystems.com/post/how-quickly-publish-restful-apis...
it might suit you.
Thanks for the help!
Thanks for noticing! Updated the link.
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue