This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
feat: (experiment) set id and *at fields readOnly in OAS3 #166
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was curious what effect more accurate
readOnly
marking would have on the generated go. Apparently none 😅This draft can serve as a patch for upstream accuracy changes. It makes
id
,*_at
(hand-picked, alll?), andstatus
fieldsreadOnly
.It is somewhat academic since the request schemas are generally distinct from the response schemas. I think it would be safe to argue that every field in the request schemas should be
writeOnly
today while every field in the response schemas should bereadOnly
.I'm optimistic that a representation of the OAS3 schemas can someday offer unified "Foo" schemas, serving as response, update, and create schemas by taking advantage of
readOnly
andwriteOnly
.Until that time, it may be confusing to have inconsistency where some fields are explicitly marked
readOnly
while others are not, especially where the request and response schemas are separate.Perhaps too optimistic:
The most practical approach may be to define the base common schema with readOnly and writeOnly fields and then extend that schema for Create and/or Update as needed to define immutable fields. However, offering a schema that sometimes presents Create/Update schemas may lead to confusion.
Similar improvements to make:
id
,href
,created_at
fields should be required in root response objects (when present)href
should also be globally readOnly.dependentRequired
? Add support for dependentRequired OpenAPITools/openapi-generator#13085 (comment)The change was automated and mechanical with a manual (and painful)
git add -p
to dismiss unwantedyaml
formatting changes. (Challenge: how fast can yous
,<enter>
,y
,<enter>
,n
,<enter>
, ... without having toK
).If a standard formatting was applied to the schema files I could have applied that formatting after running this script. The diff would have been minimized.
(updated to require
id
when present)