Repository navigation
Commit 0393d39
authored
feat: add support for
* feat: add support for `oneOf` in sttp4 client
* fix: pass `Option[String]` directly to .header
* fix: use oneOf mapping to map discriminator values to types
* fix: remove unecessary whitespaces
* fix: generate samples, make a new one for sttp4-circe
* fix: make partial function total
* fix: only use semiauto derivation
On large APIs this can dramatically speed up compilation.
* fix: missing comma
* fix: re-run generate-samples script
* docs: update documentation
* fix: spaces, not tabs
* ci: add new samples directory
* fix: bump scala version
* fix: url-form-encoded cases
* chore: regenerate sttp4 samples after upstream merge
* fix: sttp4 json4s JsonSupport uses sealed trait serializers instead of Enumeration-based EnumNameSerializer
The json4s variant of JsonSupport.scala used EnumNameSerializer which
expects Scala Enumeration types, but sttp4 model templates generate
sealed traits with case objects for enums. This caused compilation
errors since the types are incompatible.
Replace EnumNameSerializer with direct references to the implicit
Serializer objects already defined in each enum's companion object.
* fix: sttp4 oneOf with parent properties - resolve aliased children, propagate parent props
When a schema has both its own properties and a oneOf composition,
the sttp4 generator previously had three issues:
1. Empty oneOf children (no type, no properties) were silently dropped
because DefaultCodegen's unaliasSchema treated them as type aliases,
replacing the model name with the language type (e.g. io.circe.Json).
2. Parent-owned properties (e.g. cancellation_datetime) were lost
entirely - they didn't appear on the sealed trait or any child.
3. Sibling properties from other oneOf children could contaminate
each child's vars list via DefaultCodegen's property merging.
This fix:
- Resolves aliased oneOf children by looking at the original OpenAPI
schema's $refs to restore correct model names
- Identifies parent-owned properties and propagates them to each
child model's allVars so they appear in generated case classes
- Renders parent properties as abstract def members on the sealed
trait for compile-time enforcement
- Adds a test covering the CancellationInfo pattern (parent with
properties + oneOf with empty and non-empty children)
* fix: use wrapper composition for shared oneOf members in sttp4 client
When a schema is referenced by multiple oneOf parents (e.g., Dog and Cat
used by both Pet and Animal), the generator cannot inline them into any
single parent. Previously this produced broken code: sealed traits with
no subtypes, causing circe derivation and json4s serialization to fail.
This fix introduces wrapper composition for shared members: each parent
generates wrapper case classes (e.g., DogPet, CatAnimal) inside its
companion object that delegate to the standalone type. Hand-written
codecs replace semiauto derivation when wrappers are present.
Exclusive members (used by only one parent) continue to be inlined
directly, preserving the existing behavior.
Fixes compilation errors reported in PR #22916.
* fix: new issues after merging master branch
* fix: use propertyBaseName for discriminator in sttp4 serialization
When the discriminator property name is a Scala keyword (e.g., `type`),
the codegen escapes it with backticks for use as a Scala identifier.
However, the serialization templates (circe and json4s) were using
`discriminator.propertyName` which contains the escaped form, producing
incorrect JSON field names like `\`type\`` instead of `type`.
Switch all 10 usages in model.mustache to `discriminator.propertyBaseName`
which holds the original, unescaped wire name from the OpenAPI spec.
Add test case with Shape/Circle/Square using `type` as discriminator.oneOf in sttp4 client (#22916)1 parent 99662a2 commit 0393d39
46 files changed
Lines changed: 2213 additions & 149 deletions
File tree
- .github/workflows
- bin/configs
- docs/generators
- modules/openapi-generator/src
- main
- java/org/openapitools/codegen/languages
- resources/scala-sttp4
- test
- java/org/openapitools/codegen/scala
- resources/3_0/scala
- samples/client/petstore
- scala-sttp4-circe
- .openapi-generator
- project
- src/main/scala/org/openapitools/client
- api
- core
- model
- scala-sttp4
- src/main/scala/org/openapitools/client
- api
- core
- model
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | | - | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 13 | + | |
| 14 | + | |
38 | 15 | | |
39 | 16 | | |
40 | 17 | | |
| |||
43 | 20 | | |
44 | 21 | | |
45 | 22 | | |
46 | | - | |
| 23 | + | |
47 | 24 | | |
48 | 25 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 26 | + | |
58 | 27 | | |
59 | 28 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments