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

Read-only but required fields are defined as pointers #778

Open
acabarbaye opened this issue Oct 7, 2022 · 1 comment
Open

Read-only but required fields are defined as pointers #778

acabarbaye opened this issue Oct 7, 2022 · 1 comment

Comments

@acabarbaye
Copy link

In Open Api spec, https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#fixed-fields-20, there is the following statement:

If the property is marked as readOnly being true and is in the required list, the required will take effect on the response only.
Therefore, if a field is set as required and readOnly, it should not be considered as optional in the type used by server stubs since it must be in the response.

Since #547 however, all read-only fields have been defined as pointers in the generated types even if there are in the required list. Could we make the generation of types different whether it is for consumption by clients or by servers so that, the presence of required read-only fields is enforced in response and required write only-fields in requests?

@benmoss
Copy link

benmoss commented Apr 24, 2024

This is already supported by #605. You just need an config file and to have it contain

compatibility:
  disable-required-readonly-as-pointer: true

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

2 participants