apple / apple/swift-openapi-generator

Add readyOnly/writeOnly support

Open
#807 4 comments 0 reactions 0 assignees View on GitHub
area/generator kind/feature
Dominant language
Swift
Stars
2k
Forks
182
Avg merge
13h 28m
Merged PRs (30d)
5

Description

### Motivation

Currently the generator does not support readOnly and writeOnly, which is present in both 3.0 and 3.1. These attributes can be useful when generating RESTful APIs, for example if you have an ID that is generated on the server, so when you POST, there should not be a required ID field. but when you GET, the ID field is required in the response. The result would be that the same component would sometimes have a field that is optional, and sometimes not, depending on usage context.

### Proposed solution

I guess adding this is not trivial, the generator would have to generate two different versions of components, one for the request, and one for the response? Or would there be a smarter way of doing this?

### Alternatives considered

_No response_

### Additional information

Is there a way you people currently work around this? Do you manually maintain two versions of the same component in the yaml file for example?

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are named. Start by reviewing how the generator handles OpenAPI 3.0 and 3.1 schemas and component generation, then determine whether request and response variants are required; done means a decided design and documented behavior for readOnly and writeOnly fields.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, swift
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.