You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Read-Only and Write-Only Properties
You can use the readOnly and writeOnly keywords to mark specific properties as read-only or write-only. This is useful, for example, when GET returns more properties than used in POST – you can use the same schema in both GET and POST and mark the extra properties as readOnly. readOnly properties are included in responses but not in requests, and writeOnly properties may be sent in requests but not in responses.
openapi-typescript does not handle readOnly and writeOnly properly even by that definition though, see issue #604
A definition with an individual readonly property does not produce a type/interface definition with a readonly property.
openapi-typescript
6.1.0
v18.12.1
Windows 10
Reproduction
a YAML definition like this:

Expected result
...should produce a readonly property like this:

but it does not...
Solution proposal
Line 174
in\transform\schema-object.ts
is currently:if (ctx.immutableTypes || schemaObject.readOnly) key = tsReadonly(key);
and should(?) be:
if (ctx.immutableTypes || schemaObject.readOnly || ("readOnly" in v && v.readOnly)) key = tsReadonly(key);
Also notice that no test exists for the "readonly" case in
schema-object-test.ts
.Question
I tried to push this fix to this repo on a new branch (to open a PR), but got a HTTP 403.
Hopefully someone else can submit this fix instead?
The text was updated successfully, but these errors were encountered: