Commit 12fd597
* Fix #375: support OpenAPI 3.1 array-valued type (unions & nullable)
OpenAPI 3.1 / JSON Schema 2020-12 allows a schema's `type` to be an array,
e.g. type: ["string", "null"] (the nullable idiom that replaces 3.0's
`nullable: true`, and general unions). ApiTool.getType() read the type via
JsonNode.textValue(), which returns null for an array node and collapsed to
"", so every isObject/isArray/isString/isNumber/isDateTime predicate and
MapperUtil.getSimpleType failed -> the generator silently produced wrong or
empty types for those fields.
- ApiTool.getType: when `type` is an array, resolve to the first non-"null"
entry ("null" only marks the type as nullable). All the isX predicates and
getSimpleType then work unchanged for union/nullable types.
- MapperUtil.processNumber: read the type via ApiTool.getType instead of
schema.get("type").asText(), so array-valued numeric types resolve.
- Add TypeConstants.NULL.
- Add a 3.1.0 regression fixture (testOpenApi31Types) covering ["string",
"null"], ["integer","null"], ["number","null"]+double, int64 and a plain
array, with golden assets.
Bumps version 6.3.2 -> 6.4.0 across the engine, maven and gradle modules.
Non-array `type` handling is unchanged, so existing 3.0 specs are unaffected.
Follow-up 3.1 items (examples array, $ref siblings, webhooks) tracked in #375.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Support OpenAPI 3.1 top-level webhooks (#375)
OpenAPI 3.1 adds a top-level `webhooks` object: a map of named Path Item
Objects describing out-of-band requests. The generator only iterated
`paths`, so webhooks were ignored - no handler interface, no payload models.
Add OpenApiUtil.mergeWebhooksIntoPaths, invoked right after parsing in
OpenApiGenerator.processFile. Each webhook (keyed by name) is merged into
`paths` under a "/"-prefixed key so the existing pipeline generates a
handler interface for its operations and the request/response payload
models. `paths` is created if the contract has none, and existing `paths`
entries are never overwritten.
Adds a 3.1.0 webhooks-only regression fixture (testWebhooks) with golden
assets (NewPetApi + PetDTO).
Stacked on the 6.4.0 array-type work (#376); both are part of the 3.1
support milestone, so the version stays 6.4.0.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Default tags on tag-less webhook operations to avoid NPE
Webhook operations normally omit `tags`, but createOperation requires
one (Objects.requireNonNull), so a realistic tag-less webhook crashed
with a NullPointerException in the default by-url grouping mode - and
was silently skipped in tag-grouping mode. The prior test masked this
by giving the webhook explicit tags.
mergeWebhooksIntoPaths now defaults each webhook operation's tags to the
webhook name when absent/empty, and skips blank keys (guards the
pathUrl.split()[1] grouping). The testWebhooks fixture is updated to the
realistic tag-less shape to cover this.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Harden 3.1 type/webhook handling and add edge-case tests
getType: extract array-type resolution into a helper. A genuine multi-type
union (e.g. ["string","integer"]) now logs a warning and uses the first
concrete type; a "null"-only/empty type array falls back to `object`
instead of an empty type string.
Adds edge-case regression fixtures:
- testOpenApi31Union: union -> String (+warning), ["null"] -> Object
- testWebhookPathCollision: webhook name colliding with an existing path
is dropped (existing paths take precedence).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Annotate Gradle tasks with @DisableCachingByDefault
Gradle 9.x plugin validation fails the build when a task type is neither
@CacheableTask nor @DisableCachingByDefault. OpenApiTask and AsyncApiTask
are code generators whose spec-file inputs are not declared as cacheable
inputs, so caching is disabled explicitly with a documented reason.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: update thollander/actions-comment-pull-request to v2 (Node 20 deprecated)
---------
Co-authored-by: joseegarcia <jose.garcia@disashop.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a549c5f commit 12fd597
16 files changed
Lines changed: 736 additions & 26 deletions
File tree
- .github/workflows
- multiapi-engine/src
- main/java/com/sngular/api/generator/plugin
- common/tools
- openapi
- utils
- test
- java/com/sngular/api/generator/plugin/openapi
- resources/openapigenerator
- testOpenApi31Union
- assets
- testWebhookPathCollision
- assets
- testWebhooks
- assets
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
Lines changed: 21 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
224 | 226 | | |
225 | 227 | | |
226 | 228 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
236 | 239 | | |
237 | | - | |
238 | 240 | | |
239 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
240 | 250 | | |
241 | 251 | | |
242 | 252 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
Lines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
95 | 143 | | |
96 | 144 | | |
97 | 145 | | |
| |||
Lines changed: 88 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
150 | 171 | | |
151 | 172 | | |
152 | 173 | | |
153 | 174 | | |
154 | 175 | | |
155 | | - | |
| 176 | + | |
156 | 177 | | |
157 | 178 | | |
158 | 179 | | |
| |||
777 | 798 | | |
778 | 799 | | |
779 | 800 | | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
780 | 855 | | |
781 | 856 | | |
782 | 857 | | |
| |||
793 | 868 | | |
794 | 869 | | |
795 | 870 | | |
796 | | - | |
797 | | - | |
798 | | - | |
| 871 | + | |
799 | 872 | | |
800 | | - | |
| 873 | + | |
801 | 874 | | |
802 | | - | |
| 875 | + | |
803 | 876 | | |
804 | | - | |
| 877 | + | |
805 | 878 | | |
806 | | - | |
| 879 | + | |
807 | 880 | | |
808 | | - | |
| 881 | + | |
809 | 882 | | |
810 | | - | |
| 883 | + | |
811 | 884 | | |
812 | | - | |
813 | | - | |
814 | | - | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
815 | 890 | | |
816 | 891 | | |
817 | 892 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
88 | 94 | | |
89 | 95 | | |
90 | 96 | | |
| |||
Lines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
Lines changed: 46 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
0 commit comments