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
"only" option not used in Flask-Rebar #240
Comments
Just to clarify what the problem is, when Here is a minimal, reproducible example: # app.py
from marshmallow import Schema, fields
from flask_rebar import Rebar
from flask import Flask
class FooSchema(Schema):
bar = fields.Int()
baz = fields.Int()
rebar = Rebar()
registry = rebar.create_handler_registry(prefix="/api")
foo = {"bar": 1, "baz": 2}
@registry.handles(
rule="/foo",
response_body_schema=FooSchema(),
)
def foo():
return foo
@registry.handles(
rule="/foo/baz",
response_body_schema=FooSchema(only=["baz"])
)
def only_baz():
return foo
app = Flask("repro")
rebar.init_app(app) $ curl localhost:5000/api/swagger
...
"definitions": {
"FooSchema": {
"properties": {
"baz": {
"type": "integer"
}
},
... Note that the Also note that this is exhibiting "last one wins" behavior. If you swap the order in which the @ghuser2021 said he could work around the issue by not using |
Seems like Flask-Rebar is not checking for "only" option for fields in a model. May be it could check for the use of "only" and when encountered, warn or error that it is currently not supported.
@jab suggested I create this issue.
Following is an example:
@registry.handles(
rule="get_upload_status/<doc_id>",
method="GET",
response_body_schema={
200: Upload(
only=[
"upload_status",
"updated_time",
]
)
},
tags=["General"],
)
The text was updated successfully, but these errors were encountered: