-
Notifications
You must be signed in to change notification settings - Fork 341
Open
Labels
bugSomething isn't workingSomething isn't working
Description
This might be related to the recent wildcard field changes, e.g. #24.
When using a wildcard field with nested models, the resulting documentation contains three levels: *
, <*>
, and the nested model, where I would expect just two: The key <*>
and the nested model. Example values in the doc also contains an extra nested level.
Please note, the actual output of the marshaled model in get is correct, only the swagger doc is wrong.
Code
from flask import Flask
from flask_restx import Resource, Api, fields
app = Flask(__name__)
api = Api(app)
nested_model = api.model('Nested model', {'nested_string': fields.String()})
wild = fields.Wildcard(fields.Nested(nested_model))
wildcard_model = api.model('Wildcard model', {'*': wild})
@api.route('/hello')
class HelloWorld(Resource):
@api.marshal_with(wildcard_model)
def get(self):
return {
'foo': {
'nested_string': 'foo'
},
'bar': {
'nested_string': 'bar'
}
}
if __name__ == '__main__':
app.run(debug=True)
Repro Steps (if applicable)
- Run example above
- View documentation at http://localhost:5000
Actual model doc
Expected model doc
Only one level of *, not two.
Actual example value doc
{
"*": {
"additionalProp1": {
"nested_string": "string"
},
"additionalProp2": {
"nested_string": "string"
},
"additionalProp3": {
"nested_string": "string"
}
}
}
Expected example value doc
{
"additionalProp1": {
"nested_string": "string"
},
"additionalProp2": {
"nested_string": "string"
},
"additionalProp3": {
"nested_string": "string"
}
}
or
{
"*": {
"nested_string": "string"
}
}
Actual output of get (correct)
{
"bar": {
"nested_string": "bar"
},
"foo": {
"nested_string": "foo"
}
}
Environment
- Python 3.7
- Flask 1.1.1
- Flask-RESTX 0.1.1
esztermarton, Gaasmann, ilfrich and tvinagre
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working