Skip to content

Commit d21b7af

Browse files
author
simonbility
committed
WIP Proposal
1 parent 4edb661 commit d21b7af

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

Sources/swift-openapi-generator/Documentation.docc/Proposals/Proposals.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ If you have any questions, tag [Honza Dvorsky](https://github.com/czechboy0) or
5555
- <doc:SOAR-0011>
5656
- <doc:SOAR-0012>
5757
- <doc:SOAR-0013>
58+
- <doc:SOAR-0014>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# SOAR-0014: Support Type Substitutions
2+
3+
Allow using user-defined types instead of generated ones, utilizing vendor-extensions
4+
5+
## Overview
6+
7+
- Proposal: SOAR-0014
8+
- Author(s): [simonbility](https://github.com/simonbility)
9+
- Status: **Awaiting Review**
10+
- Issue: [apple/swift-openapi-generator#375](https://github.com/apple/swift-openapi-generator/issues/375)
11+
- Implementation:
12+
- [apple/swift-openapi-generator#764](https://github.com/apple/swift-openapi-generator/pull/764)
13+
- Affected components:
14+
- generator
15+
16+
### Introduction
17+
18+
The goal of this proposal is to allow users to specify custom types for generated code using vendor extensions. This will enable users to use their own types instead of the default generated ones, allowing for greater flexibility.
19+
20+
### Motivation
21+
22+
This proposal would enable more flexibility in the generated code.
23+
Some usecases include:
24+
- Using custom types that are already defined in the user's codebase or even coming from a third party library, instead of generating new ones.
25+
- workaround missing support for `format`
26+
- Implement custom validation/encoding/decoding logic that cannot be expressed using the OpenAPI spec
27+
28+
This is intended as a "escape hatch" for use-cases that (currently) cannot be expressed.
29+
Using this comes with the risk of user-provided types not being compliant with the original OpenAPI spec.
30+
31+
32+
### Proposed solution
33+
34+
The proposed solution is to allow the `x-swift-open-api-replace-type` vendor-extension to prevent the generation of types as usual, and instead use the specified type.
35+
This should be supported anywhere within a OpenAPI document where a schema can be defined.
36+
This includes:
37+
* "TopLevel" schemas in `components.schemas`
38+
* "Inline" schema definitions in object
39+
40+
```diff
41+
42+
43+
```
44+
45+
46+
Describe your solution to the problem. Provide examples and describe how they work. Show how your solution is better than current workarounds.
47+
48+
This section should focus on what will change for the _adopters_ of Swift OpenAPI Generator.
49+
50+
### Detailed design
51+
52+
Describe the implementation of the feature, a link to a prototype implementation is encouraged here.
53+
54+
This section should focus on what will change for the _contributors_ to Swift OpenAPI Generator.
55+
56+
### API stability
57+
58+
Discuss the API implications, making sure to considering all of:
59+
- runtime public API
60+
- runtime "Generated" SPI
61+
- existing transport and middleware implementations
62+
- generator implementation affected by runtime API changes
63+
- generator API (config file, CLI, plugin)
64+
- existing and new generated adopter code
65+
66+
### Future directions
67+
68+
Discuss any potential future improvements to the feature.
69+
70+
### Alternatives considered
71+
72+
Discuss the alternative solutions considered, even during the review process itself.

0 commit comments

Comments
 (0)