Skip to content

Commit 14d4131

Browse files
authored
[Go] replace go generator with go-experimental generator (#7337)
* replace go with go-experimental * update samples * extends with abstract go class * rearrange * remove deprecated * minor fix * remove go deprecated samples * update pom, clean up samples * mark generator as deprecated
1 parent 1f50207 commit 14d4131

712 files changed

Lines changed: 37804 additions & 68642 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bin/configs/go-experimental-go-petstore-oas2.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

bin/configs/go-experimental-go-petstore.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
generatorName: go-experimental
1+
generatorName: go
22
outputDir: samples/openapi3/client/extensions/x-auth-id-alias/go-experimental
33
inputSpec: modules/openapi-generator/src/test/resources/3_0/extensions/x-auth-id-alias.yaml
4-
templateDir: modules/openapi-generator/src/main/resources/go-experimental
4+
templateDir: modules/openapi-generator/src/main/resources/go
55
additionalProperties:
66
packageName: x_auth_id_alias

bin/configs/go-petstore-oas2.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-e
44
templateDir: modules/openapi-generator/src/main/resources/go
55
additionalProperties:
66
packageName: petstore
7+
generateInterfaces: true

bin/configs/go-petstore-withXml.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

bin/configs/go-petstore.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
generatorName: go
22
outputDir: samples/openapi3/client/petstore/go/go-petstore
3-
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
44
templateDir: modules/openapi-generator/src/main/resources/go
55
additionalProperties:
66
enumClassPrefix: "true"
77
packageName: petstore
8+
disallowAdditionalPropertiesIfNotPresent: false
9+
generateInterfaces: true

docs/generators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The following generators are available:
2929
* [erlang-proper](generators/erlang-proper.md)
3030
* [flash-deprecated (deprecated)](generators/flash-deprecated.md)
3131
* [go](generators/go.md)
32-
* [go-experimental (experimental)](generators/go-experimental.md)
32+
* [go-deprecated (deprecated)](generators/go-deprecated.md)
3333
* [groovy](generators/groovy.md)
3434
* [haskell-http-client](generators/haskell-http-client.md)
3535
* [java](generators/java.md)

docs/generators/go-deprecated.md

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
---
2+
title: Config Options for go-deprecated
3+
sidebar_label: go-deprecated
4+
---
5+
6+
| Option | Description | Values | Default |
7+
| ------ | ----------- | ------ | ------- |
8+
|enumClassPrefix|Prefix enum with class name| |false|
9+
|generateInterfaces|Generate interfaces for api classes| |false|
10+
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
11+
|isGoSubmodule|whether the generated Go module is a submodule| |false|
12+
|packageName|Go package name (convention: lowercase).| |openapi|
13+
|packageVersion|Go package version.| |1.0.0|
14+
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
15+
|structPrefix|whether to prefix struct with the class name. e.g. DeletePetOpts => PetApiDeletePetOpts| |false|
16+
|withAWSV4Signature|whether to include AWS v4 signature support| |false|
17+
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default in GitHub PRs and diffs| |false|
18+
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
19+
20+
## IMPORT MAPPING
21+
22+
| Type/Alias | Imports |
23+
| ---------- | ------- |
24+
25+
26+
## INSTANTIATION TYPES
27+
28+
| Type/Alias | Instantiated By |
29+
| ---------- | --------------- |
30+
31+
32+
## LANGUAGE PRIMITIVES
33+
34+
<ul class="column-ul">
35+
<li>bool</li>
36+
<li>byte</li>
37+
<li>complex128</li>
38+
<li>complex64</li>
39+
<li>float32</li>
40+
<li>float64</li>
41+
<li>int</li>
42+
<li>int32</li>
43+
<li>int64</li>
44+
<li>interface{}</li>
45+
<li>map[string]interface{}</li>
46+
<li>rune</li>
47+
<li>string</li>
48+
<li>uint</li>
49+
<li>uint32</li>
50+
<li>uint64</li>
51+
</ul>
52+
53+
## RESERVED WORDS
54+
55+
<ul class="column-ul">
56+
<li>bool</li>
57+
<li>break</li>
58+
<li>byte</li>
59+
<li>case</li>
60+
<li>chan</li>
61+
<li>complex128</li>
62+
<li>complex64</li>
63+
<li>const</li>
64+
<li>continue</li>
65+
<li>default</li>
66+
<li>defer</li>
67+
<li>else</li>
68+
<li>error</li>
69+
<li>fallthrough</li>
70+
<li>float32</li>
71+
<li>float64</li>
72+
<li>for</li>
73+
<li>func</li>
74+
<li>go</li>
75+
<li>goto</li>
76+
<li>if</li>
77+
<li>import</li>
78+
<li>int</li>
79+
<li>int16</li>
80+
<li>int32</li>
81+
<li>int64</li>
82+
<li>int8</li>
83+
<li>interface</li>
84+
<li>map</li>
85+
<li>nil</li>
86+
<li>package</li>
87+
<li>range</li>
88+
<li>return</li>
89+
<li>rune</li>
90+
<li>select</li>
91+
<li>string</li>
92+
<li>struct</li>
93+
<li>switch</li>
94+
<li>type</li>
95+
<li>uint</li>
96+
<li>uint16</li>
97+
<li>uint32</li>
98+
<li>uint64</li>
99+
<li>uint8</li>
100+
<li>uintptr</li>
101+
<li>var</li>
102+
</ul>
103+
104+
## FEATURE SET
105+
106+
107+
### Client Modification Feature
108+
| Name | Supported | Defined By |
109+
| ---- | --------- | ---------- |
110+
|BasePath|✓|ToolingExtension
111+
|Authorizations|✗|ToolingExtension
112+
|UserAgent|✓|ToolingExtension
113+
|MockServer|✗|ToolingExtension
114+
115+
### Data Type Feature
116+
| Name | Supported | Defined By |
117+
| ---- | --------- | ---------- |
118+
|Custom|✗|OAS2,OAS3
119+
|Int32|✓|OAS2,OAS3
120+
|Int64|✓|OAS2,OAS3
121+
|Float|✓|OAS2,OAS3
122+
|Double|✓|OAS2,OAS3
123+
|Decimal|✓|ToolingExtension
124+
|String|✓|OAS2,OAS3
125+
|Byte|✓|OAS2,OAS3
126+
|Binary|✓|OAS2,OAS3
127+
|Boolean|✓|OAS2,OAS3
128+
|Date|✓|OAS2,OAS3
129+
|DateTime|✓|OAS2,OAS3
130+
|Password|✓|OAS2,OAS3
131+
|File|✓|OAS2
132+
|Array|✓|OAS2,OAS3
133+
|Maps|✓|ToolingExtension
134+
|CollectionFormat|✓|OAS2
135+
|CollectionFormatMulti|✓|OAS2
136+
|Enum|✓|OAS2,OAS3
137+
|ArrayOfEnum|✓|ToolingExtension
138+
|ArrayOfModel|✓|ToolingExtension
139+
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
140+
|ArrayOfCollectionOfModel|✓|ToolingExtension
141+
|ArrayOfCollectionOfEnum|✓|ToolingExtension
142+
|MapOfEnum|✓|ToolingExtension
143+
|MapOfModel|✓|ToolingExtension
144+
|MapOfCollectionOfPrimitives|✓|ToolingExtension
145+
|MapOfCollectionOfModel|✓|ToolingExtension
146+
|MapOfCollectionOfEnum|✓|ToolingExtension
147+
148+
### Documentation Feature
149+
| Name | Supported | Defined By |
150+
| ---- | --------- | ---------- |
151+
|Readme|✓|ToolingExtension
152+
|Model|✓|ToolingExtension
153+
|Api|✓|ToolingExtension
154+
155+
### Global Feature
156+
| Name | Supported | Defined By |
157+
| ---- | --------- | ---------- |
158+
|Host|✓|OAS2,OAS3
159+
|BasePath|✓|OAS2,OAS3
160+
|Info|✓|OAS2,OAS3
161+
|Schemes|✗|OAS2,OAS3
162+
|PartialSchemes|✓|OAS2,OAS3
163+
|Consumes|✓|OAS2
164+
|Produces|✓|OAS2
165+
|ExternalDocumentation|✓|OAS2,OAS3
166+
|Examples|✓|OAS2,OAS3
167+
|XMLStructureDefinitions|✗|OAS2,OAS3
168+
|MultiServer|✗|OAS3
169+
|ParameterizedServer|✓|OAS3
170+
|ParameterStyling|✗|OAS3
171+
|Callbacks|✗|OAS3
172+
|LinkObjects|✗|OAS3
173+
174+
### Parameter Feature
175+
| Name | Supported | Defined By |
176+
| ---- | --------- | ---------- |
177+
|Path|✓|OAS2,OAS3
178+
|Query|✓|OAS2,OAS3
179+
|Header|✓|OAS2,OAS3
180+
|Body|✓|OAS2
181+
|FormUnencoded|✓|OAS2
182+
|FormMultipart|✓|OAS2
183+
|Cookie|✓|OAS3
184+
185+
### Schema Support Feature
186+
| Name | Supported | Defined By |
187+
| ---- | --------- | ---------- |
188+
|Simple|✓|OAS2,OAS3
189+
|Composite|✓|OAS2,OAS3
190+
|Polymorphism|✗|OAS2,OAS3
191+
|Union|✗|OAS3
192+
193+
### Security Feature
194+
| Name | Supported | Defined By |
195+
| ---- | --------- | ---------- |
196+
|BasicAuth|✓|OAS2,OAS3
197+
|ApiKey|✓|OAS2,OAS3
198+
|OpenIDConnect|✗|OAS3
199+
|BearerToken|✗|OAS3
200+
|OAuth2_Implicit|✓|OAS2,OAS3
201+
|OAuth2_Password|✗|OAS2,OAS3
202+
|OAuth2_ClientCredentials|✗|OAS2,OAS3
203+
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
204+
205+
### Wire Format Feature
206+
| Name | Supported | Defined By |
207+
| ---- | --------- | ---------- |
208+
|JSON|✓|OAS2,OAS3
209+
|XML|✓|OAS2,OAS3
210+
|PROTOBUF|✗|ToolingExtension
211+
|Custom|✗|OAS2,OAS3

docs/generators/go.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ sidebar_label: go
55

66
| Option | Description | Values | Default |
77
| ------ | ----------- | ------ | ------- |
8+
|disallowAdditionalPropertiesIfNotPresent|Specify the behavior when the 'additionalProperties' keyword is not present in the OAS document. If false: the 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications. If true: when the 'additionalProperties' keyword is not present in a schema, the value of 'additionalProperties' is set to false, i.e. no additional properties are allowed. Note: this mode is not compliant with the JSON schema specification. This is the original openapi-generator behavior.This setting is currently ignored for OAS 2.0 documents: 1) When the 'additionalProperties' keyword is not present in a 2.0 schema, additional properties are NOT allowed. 2) Boolean values of the 'additionalProperties' keyword are ignored. It's as if additional properties are NOT allowed.Note: the root cause are issues #1369 and #1371, which must be resolved in the swagger-parser project.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>when the 'additionalProperties' keyword is not present in a schema, the value of 'additionalProperties' is automatically set to false, i.e. no additional properties are allowed. Note: this mode is not compliant with the JSON schema specification. This is the original openapi-generator behavior.</dd></dl>|true|
89
|enumClassPrefix|Prefix enum with class name| |false|
910
|generateInterfaces|Generate interfaces for api classes| |false|
1011
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
@@ -13,6 +14,7 @@ sidebar_label: go
1314
|packageVersion|Go package version.| |1.0.0|
1415
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
1516
|structPrefix|whether to prefix struct with the class name. e.g. DeletePetOpts =&gt; PetApiDeletePetOpts| |false|
17+
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and onlye one match in oneOf's schemas) will be skipped.| |false|
1618
|withAWSV4Signature|whether to include AWS v4 signature support| |false|
1719
|withGoCodegenComment|whether to include Go codegen comment to disable Go Lint and collapse by default in GitHub PRs and diffs| |false|
1820
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
631631
}
632632
}
633633

634-
if (this instanceof GoClientExperimentalCodegen && model.isEnum) {
634+
if (this instanceof GoClientCodegen && model.isEnum) {
635635
imports.add(createMapping("import", "fmt"));
636636
}
637637

0 commit comments

Comments
 (0)