-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
In schema objects, using allOf to add a description to a $ref? #2033
Comments
In terms of JSON Schema, this is the recommended approach. The latest draft formalizes some internal mechanisms to help tooling make use of it, but if Swagger Editor already handles it correctly then that's great! Note that OAS 3.1 is likely to adopt the latest JSON Schema draft per #1977 , which will allow putting the |
Closing as above, thanks @handrews |
@handrews Thank you very much! |
It seems a somewhat common challenge is the inability to combine
$ref
with other attributes. For my use case, building schema objects and leveraging reusable models, the only additional attribute I need is adding adescription
for how the model is being used in context. I think I have a workaround and am hoping more knowledgeable folks can give feedback.An example resuable model is an
imageAsset
schema representing an item from a digital asset repository:Its description is not useful for explaining the purpose of the image asset in the referencing schema. Let's say I have a schema for
restaurant
that includes an image:This pulls in the description from
imageAsset
, which is irrelevant to the context. I need to set a description to explain the meaning ofoverviewImage
.Putting the
$ref
inside anallOf
seems to allow that:The syntax validates and the web-based Swagger Editor's preview shows the desired result. Is this a reasonable approach?
The text was updated successfully, but these errors were encountered: