desktop
desktop copied to clipboard
`readOnly` schema field not respected in generated documentation
The readOnly
field referenced in the OASv2 specification does not appear to be respected when converting a spec to API documentation. Per the spec:
This means that it MAY be sent as part of a response but MUST NOT be sent as part of the request.
So anything with a readOnly
option set to true
should not be displayed in the API request documentation, only the response.
As a workaround to this issue, the same effect as readOnly
(and writeOnly
, which was added with OASv3) can be accomplished by using the Stoplight CRUD Builder (the "CRUD" button in the Next UI) and marking objects as read-only and write-only. Since the CRUD builder generates models via pure object modeling, read-only and write-only properties can be created that way.
This would save a lot of editing complexity for my teams - much of the proliferation of model variations and inheritance is to allow for "system assigned" fields like id
, created_on
timestamps, etc.
The proposed workaround produces separate models rather than nicely leveraging the spec to have a single model. Your rendered docs display "readOnly" as a validation when true, but the field should be hidden/removed completely and not added to the "Send Test Request" body.
Also, the schema editor does not have a "readOnly" toggle. I have to go to "source" to add the boolean manually.
May I know when there will be an option for readonly flags?