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

example/default ignored when using ref #745

Closed
floggle opened this issue Dec 15, 2018 · 4 comments
Closed

example/default ignored when using ref #745

floggle opened this issue Dec 15, 2018 · 4 comments

Comments

@floggle
Copy link

floggle commented Dec 15, 2018

I have the following:

    "components": {
        "schemas": {
            "error_model": {
                "properties": {
                    "success": {
                        "default": false,
                        "example": false,
                        "$ref": "#/components/schemas/success_flag"
                    },
				}
			},
            "success_flag": {
                "description": "A flag indicating whether the request was successfully completed or not.\n\n**Note**: A successful request does _not_ mean results were returned. Check the `total_results` field for that",
                "type": "boolean"
            }
		}
	}
}

The default and example flags are both being ignored and I'm seeing "success: true" on the redoc example.

I expected that the parent's properties would be the ones exemplified, similar to how "description" uses the highest level one.

@m-mohr
Copy link
Contributor

m-mohr commented Dec 17, 2018

You can't set properties on the same level as a $ref. $ref replaces everything on the same level. So it works as expected by OpenAPI. See the section "$ref and Sibling Elements" here: https://swagger.io/docs/specification/using-ref/

@floggle
Copy link
Author

floggle commented Dec 28, 2018

Ok, thanks. I'm running this OpenAPI file through three OpenAPI linters and while I don't have the code any more, I'm fairly sure I wouldn't have reported this if they were complaining about my spec.

That said, the OpenAPI 3 spec (what I'm using) appears to agree with you - https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#referenceObject
"This object cannot be extended with additional properties and any properties added SHALL be ignored."
I guess the linters need some work!
Thanks!

@ymarillet
Copy link

you can use allOf feature though

@RomanHotsiy
Copy link
Member

Closing this. Thanks @m-mohr for answering here 🙇 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants