Skip to content
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

How to specify attributes (such as dump_only,...) on Nested fields? #108

lafrech opened this issue Feb 16, 2017 · 2 comments


Copy link

commented Feb 16, 2017

Say you have a dump_only Nested field in your model.

The model reads:

class Parent(Schema):

    child = Nested(Child, dump_ony=True)

Assuming you added Child to the definitions, the spec then looks like

    "Parent": {
      "properties": {
        "child": {
          "$ref": "#/definitions/Child", 
          "readOnly": true
      "type": "object"

Unfortunately, this is invalid OpenAPI spec: swagger-api/swagger-js#402

I get this warning in ReDoc:

Other properties are defined at the same level as $ref at "#/definitions/Parent/properties/child". They are IGNORED according to the JsonSchema spec

Has anyone here been facing this already?

Should we use the AllOf trick described here?


This comment has been minimized.

Copy link
Member Author

commented Mar 3, 2017

I tried to expose the issue in the tests, but apparently, the validation in swagger-tools does not raise any error about that, so I don't have a failing test.

Here's a quick fix attempt using allOf to wrap all nested schemas:


This comment has been minimized.

Copy link

commented Mar 3, 2017

Good catch. I think allOf is the correct solution, but it would be nice if it were only used when needed, i.e. only wrap in allOf if there are additional properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.