schema
class method to get OpenAPI schema
#269
Replies: 2 comments
-
I don't use OpenAPI, but I think this sounds like a nice idea. I wanted to share a couple of gems that might show some "prior art" about defining schemas: https://github.com/jgaskins/primalize and https://github.com/voxpupuli/json-schema -- just in case these are helpful to review. As for the Thanks! |
Beta Was this translation helpful? Give feedback.
-
That's a great idea! It could be used as a part of bigger toolset to generate OpenAPI specification for whole API. |
Beta Was this translation helpful? Give feedback.
-
Abstract
OpenAPI is a common way to define API schema. I think it's convenient if we could export the schema of the resource into OpenAPI compatible JSON (or Hash) so that we can develop API first and then tell other developers how that API works.
Example
It works like below:
The output of
schema
will look something like below:Discussions
We can provide type information that's required by OpenAPI, but we cannot provide requirement information now. I'm considering adding
on_nil
option toattributes
call so that withon_nil: :raise
it's required attribute.Beta Was this translation helpful? Give feedback.
All reactions