-
Notifications
You must be signed in to change notification settings - Fork 531
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
Parser ignore readOnly/writeOnly on property with $ref #2036
Comments
I believe this issue extends to more than just The issue seems to be the way the OpenAPIDeserializer handles refs: JsonNode ref = node.get("$ref");
if (ref != null) {
if (ref.getNodeType().equals(JsonNodeType.STRING)) {
// ...
return schema; // uh-oh!
} else {
result.invalidType(location, "$ref", "string", node);
return null;
}
}
getCommonSchemaFields(node, location, result, schema); Here, if a ref is found, the ref is resolved and then the schema is returned as-is. The following steps -- most notably |
This might actually be intended behaviour, because the OpenAPI 3.1 specification states this for ref objects:
For proper composition, this OpenAPI construct should do the trick instead: Order:
type: object
properties:
id:
type: string
operations:
type: array
items:
$ref: '#/components/schemas/Operation'
readOnly: true
customer:
allOf:
- $ref: '#/components/schemas/Customer'
readOnly: true # readOnly should not be lost anymore |
I've gotten some clarifications in smallrye/smallrye-open-api#2097 (comment) and as I now understand, the mentioned schema should work in OpenAPI 3.1, because the
I also found an example in the spec that does the same (section 7.7.1.1: )
So as far as I understand, this is a valid use-case and should be supported in OpenAPI 3.1, especially since this appears to be how e.g. smallrye-openapi generates all refs now. |
Swagger Parser correctly allows siblings for |
Hey, thanks for clarifying! I was under the impression that I did test with OpenAPI 3.1, but I just checked and indeed I didn't, sorry for that 🙏 turns out the issue I'm facing is actually an issue in openapi-generator, not in the swagger-parser: OpenAPITools/openapi-generator#20304 |
The Parser ignore the
readOnly
attribute on the propertyOrder.customer
The text was updated successfully, but these errors were encountered: