Skip to content

Properly handle readOnly and writeOnly properties #28

@tajnymag

Description

@tajnymag

Describe the solution you'd like
As described at original issue and pull request openapi-typescript-codegen does not handle readOnly and writeOnly properties of openapi schemas.

With these properties, it is easier to model properties not for modifiable models.

OpenAPI example:

type: object
properties:
  id:
    # Returned by GET, not used in POST/PUT/PATCH
    type: integer
    readOnly: true
  username:
    type: string
  password:
    # Used in POST/PUT/PATCH, not returned by GET
    type: string
    writeOnly: true

Expected example types (not necessary to be generated separately, as @tiholic suggested in his PR):

UserGetResponse: { id: number, username?: string }
UserPostRequest: { id: number, username?, password?: string }
UserPutRequest: { id: number, username?, password?: string }
UserPatchRequest: { id: number, username?, password?: string }

Metadata

Metadata

Assignees

Labels

feature 🚀New feature or requestprioritized 🚚This issue has been prioritized and will be worked on soon

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions