-
Notifications
You must be signed in to change notification settings - Fork 38
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
registry.add_supplemental_schemas #48
Conversation
…al schemas to swagger, in addition to those used by the API handlers.
# Conflicts: # flask_rebar/swagger_generation/swagger_generator.py
@joeb1415 Just curious, why does vars need to be a Dict field and not a nested schema referencing Template_1_Schema? still see the value in being able to reference other models just curious about this particular use case. |
@brockhaywood There are many |
Ah got it, conditional templates? |
It seems like what you actually want is the But this field sucks. And OpenAPI 3.0 replaces this with the proper jsonSchema way of doing this: If you had one of these features available, would you need this change? I'd rather avoid things that both require manual tweaking of the swagger, especially those that aren't really sanctioned in the swagger spec. But I prefer practicality over purity, so I'm open to this change if we really need it. |
Did you look into the possibility of just adding these schemas into the client package we generate / did that not work? I'm not sure this belongs in rebar, and I'm not sure that adding it to rebar actually gets us anything over doing that, since the generated client won't know which template schema to validate against either way. (Well, I guess it adds a little consistency in that the schemas in the package are the regular swagger-codegen schemas instead of Marshmallow schemas, hmm...) |
@barakalon yeah if we could do something like this that would be awesome!
|
This looks interesting: |
That seems to be the blessed one: marshmallow-code/marshmallow#649 Doesn't seem too bad to add a converter that uses the However, since
Or make it a separate plugin. |
Hey folks, sorry I'm late to the party here (having just joined the team :D) - Doing some PR housekeeping.. If I've followed the conversations accurately, is it fair to say this will get rolled in with OpenAPI 3.0 support WIP? |
Closing in favor of OpenAPI 3.0 support which should make this irrelevant |
Add
registry.add_supplemental_schemas
function to export supplemental schemas to swagger, in addition to those used by the API handlers.In my app, I have a handler:
With:
Elsewhere, I validate the vars against the template according to various template schemas:
I would like to export these template schemas in the swagger definition, so others can know what to expect to send to my handler in the
vars
dictionary param.This PR introduces a registry function
add_supplemental_schemas
to support this. The function can accept a single schema, or for convenience, a directory containing all the supplemental schemas.cc: @barakalon