openapi3: allow Extensions next to $ref in SchemaRef#901
openapi3: allow Extensions next to $ref in SchemaRef#901fenollp merged 1 commit intogetkin:masterfrom
Conversation
|
Oh snap, looks like refs.go is auto generated. Please see if you like this change, then I make the change to |
|
I made the following changes:
I think the only "question" is if |
|
This is great work thank you! WRT non x-.. in Extensions you're right: let's just keep the x-.. keys in here for now anyway |
|
I rebased on the latest master. Hoping to get this into the next release. |
|
Hi @fenollp, I rebased again on the latest master. Hoping to get this into the next release. |
ba91e23 to
63ca84c
Compare
| // error if extensions (fields starting with 'x-') are found as | ||
| // siblings for $ref fields. Non-extension fields are prohibited | ||
| // unless allowed explicitly with the AllowExtraSiblingFields option. | ||
| func ProhibitExtensionsWithRef() ValidationOption { |
There was a problem hiding this comment.
Do you mind renaming to ˋDisallow..ˋ? The other options in there start with Allow.. or Disallow.. (well, most)
See #900 for full details and use-case. If this approach is agreed upon, I can extend to all *Refs (e.g. CallbackRef, ExampleRef, ResponseRef, etc.)
Captures
x-orderintoSchemaRef.ExtensionsOnly extensions (those starting with 'x-') are captured. This is because extra attributes are technically not allowed by the spec, but also to maintain the way
JSONLookupworks. For example:Doesn't change:
thingIDRef.JSONLookup("type")will continue to return "integer" as overriding thetypenext to the ref is not allowed and bad practice, in my opinion. There could be a use-case for stuff likenullable, but for now I would rather not change the behavior.Does change:
thingIDRef.JSONLookup("x-order"). Today, 2, as it goes back to the $ref definition. After this change it'll be1(value next to the $ref).Does change:
Validate()behavior. It's now okay, by default, to have extensions next to the $ref. To change this behavior, use theProhibitExtensionsWithRefoption.