Replies: 1 comment 1 reply
-
I haven’t used RSwag, but Swagger, OpenAPI, and JSONSchema (OpenAPI being an extension of JSONSchema since 3.0) all specify properties being optional by default (source):
This is why both in schema objects as well as request bodies the This library doesn’t try and assert any opinions over how it “should” be; it just tries to follow the specification as closely as possible, and that is how the specification is outlined. To make something required, just add |
Beta Was this translation helpful? Give feedback.
-
I am coming to
openapi-typescript
from a Ruby background. We use RSwag to verify our API responses against our swagger json. In effect we can say the API response is correct and ensure the schema accounts for all responses from our API call, optional fields and all. This done with Ruby's json-schema gem.As the last part we use
openapi-typescript
to generate Typescript from our swagger.json this is all good well, but it would appear RSwag is configured to be strict to require all defined properties by default unless less otherwise configured not to and we have make them otherwise optional if necessary, The Typescript generated from our swagger file makes all properties optional by default but there doesn't seem to be a way to override this?Am I missing something?
Many thanks
RobL
Beta Was this translation helpful? Give feedback.
All reactions