-
Notifications
You must be signed in to change notification settings - Fork 499
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
setting all required fields as optional should not serialize "required" as an empty array #2943
Comments
Hi @EricWittmann, I created PR Apicurio/apicurio-data-models#838 in apicurio-data-models to solve this issue. |
Interesting! Nice catch on this. I think we can go ahead with merging your PR, but for data models 2.0 I'm wondering if this logic should be captured in the data model serializer. I'll give it some thought... |
I agree, it should be better to handle this at serialization level. |
FYI I merged the PR and am trying to release data-models. Having trouble, will keep working on it. |
OK release is done successfully. |
Great thanks.
Le jeu. 14 nov. 2024, 16:51, Eric Wittmann ***@***.***> a
écrit :
… OK release is done successfully.
—
Reply to this email directly, view it on GitHub
<#2943 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJCJX5YUCFLVXI4FPSREOSD2ATBJPAVCNFSM6AAAAABRUJBOF6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZWG43DONBUHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Expected Behavior
When fields are set as required on a schema and then set back as optional so that "required" field is empty, "required" should no be serialized in json or yaml, cause empty array is invalid for some openapi versions (cf: https://community.smartbear.com/discussions/swaggerostools/empty-array-in-required-field-in-schema-object/193184)
Actual Behavior
Required field is serialized as an empty array.
Steps to Reproduce the Problem
Specifications
Cause
In apicurio-data-models, the
ChangePropertyTypeCommand
which is called when required field is changed on a property will create a new array to store required properties and will keep an empty array when all required properties are removed.Proposed solution
Call
parent.setRequiredProperties(null);
to replace empty array by null so that "required" is not serialized when empty.The text was updated successfully, but these errors were encountered: