Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,9 @@ public ModelsMap postProcessModels(ModelsMap objs) {

if (withXml) {
goDataTag += " xml:" + "\"" + cp.baseName;
if (cp.isXmlWrapped) {
goDataTag += ">" + ("".equals(cp.xmlName) ? cp.baseName : cp.xmlName);
}
if (cp.isXmlAttribute) {
goDataTag += ",attr";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,26 @@ public void testAdditionalPropertiesWithoutGoMod() throws Exception {
Path goSumFile = Paths.get(output + "/go.sum");
TestUtils.assertFileNotExists(goSumFile);
}

@Test
public void testXmlOptionsBeingUsed() throws IOException {
Map<String, Object> properties = new HashMap<>();
properties.put(GoClientCodegen.STRUCT_PREFIX, true);
properties.put(GoClientCodegen.WITH_XML, true);

File output = Files.createTempDirectory("test").toFile();
output.deleteOnExit();

final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("go")
.setAdditionalProperties(properties)
.setInputSpec("src/test/resources/3_0/petstore.yaml")
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));

DefaultGenerator generator = new DefaultGenerator();
List<File> files = generator.opts(configurator.toClientOptInput()).generate();
files.forEach(File::deleteOnExit);

TestUtils.assertFileContains(Paths.get(output + "/model_pet.go"), "tags>tag");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,25 @@ components:
type: array
items:
$ref: '#/components/schemas/ReadOnlyFirst'
ArrayTestWithWrapped:
type: object
properties:
array_of_string:
type: array
items:
type: string
xml:
wrapped: true
ArrayTestWithWrappedAndName:
type: object
properties:
array_of_string:
type: array
items:
type: string
xml:
name: item
wrapped: true
NumberOnly:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ docs/AppleReq.md
docs/ArrayOfArrayOfNumberOnly.md
docs/ArrayOfNumberOnly.md
docs/ArrayTest.md
docs/ArrayTestWithWrapped.md
docs/ArrayTestWithWrappedAndName.md
docs/Banana.md
docs/BananaReq.md
docs/Capitalization.md
Expand Down Expand Up @@ -106,6 +108,8 @@ model_apple_req.go
model_array_of_array_of_number_only.go
model_array_of_number_only.go
model_array_test_.go
model_array_test_with_wrapped.go
model_array_test_with_wrapped_and_name.go
model_banana.go
model_banana_req.go
model_capitalization.go
Expand Down
2 changes: 2 additions & 0 deletions samples/openapi3/client/petstore/go/go-petstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ Class | Method | HTTP request | Description
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
- [ArrayTest](docs/ArrayTest.md)
- [ArrayTestWithWrapped](docs/ArrayTestWithWrapped.md)
- [ArrayTestWithWrappedAndName](docs/ArrayTestWithWrappedAndName.md)
- [Banana](docs/Banana.md)
- [BananaReq](docs/BananaReq.md)
- [Capitalization](docs/Capitalization.md)
Expand Down
19 changes: 19 additions & 0 deletions samples/openapi3/client/petstore/go/go-petstore/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,25 @@ components:
type: array
type: array
type: object
ArrayTestWithWrapped:
properties:
array_of_string:
items:
type: string
type: array
xml:
wrapped: true
type: object
ArrayTestWithWrappedAndName:
properties:
array_of_string:
items:
type: string
type: array
xml:
name: item
wrapped: true
type: object
NumberOnly:
properties:
JustNumber:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# ArrayTestWithWrapped

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**ArrayOfString** | Pointer to **[]string** | | [optional]

## Methods

### NewArrayTestWithWrapped

`func NewArrayTestWithWrapped() *ArrayTestWithWrapped`

NewArrayTestWithWrapped instantiates a new ArrayTestWithWrapped object
This constructor will assign default values to properties that have it defined,
and makes sure properties required by API are set, but the set of arguments
will change when the set of required properties is changed

### NewArrayTestWithWrappedWithDefaults

`func NewArrayTestWithWrappedWithDefaults() *ArrayTestWithWrapped`

NewArrayTestWithWrappedWithDefaults instantiates a new ArrayTestWithWrapped object
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set

### GetArrayOfString

`func (o *ArrayTestWithWrapped) GetArrayOfString() []string`

GetArrayOfString returns the ArrayOfString field if non-nil, zero value otherwise.

### GetArrayOfStringOk

`func (o *ArrayTestWithWrapped) GetArrayOfStringOk() (*[]string, bool)`

GetArrayOfStringOk returns a tuple with the ArrayOfString field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetArrayOfString

`func (o *ArrayTestWithWrapped) SetArrayOfString(v []string)`

SetArrayOfString sets ArrayOfString field to given value.

### HasArrayOfString

`func (o *ArrayTestWithWrapped) HasArrayOfString() bool`

HasArrayOfString returns a boolean if a field has been set.


[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# ArrayTestWithWrappedAndName

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**ArrayOfString** | Pointer to **[]string** | | [optional]

## Methods

### NewArrayTestWithWrappedAndName

`func NewArrayTestWithWrappedAndName() *ArrayTestWithWrappedAndName`

NewArrayTestWithWrappedAndName instantiates a new ArrayTestWithWrappedAndName object
This constructor will assign default values to properties that have it defined,
and makes sure properties required by API are set, but the set of arguments
will change when the set of required properties is changed

### NewArrayTestWithWrappedAndNameWithDefaults

`func NewArrayTestWithWrappedAndNameWithDefaults() *ArrayTestWithWrappedAndName`

NewArrayTestWithWrappedAndNameWithDefaults instantiates a new ArrayTestWithWrappedAndName object
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set

### GetArrayOfString

`func (o *ArrayTestWithWrappedAndName) GetArrayOfString() []string`

GetArrayOfString returns the ArrayOfString field if non-nil, zero value otherwise.

### GetArrayOfStringOk

`func (o *ArrayTestWithWrappedAndName) GetArrayOfStringOk() (*[]string, bool)`

GetArrayOfStringOk returns a tuple with the ArrayOfString field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetArrayOfString

`func (o *ArrayTestWithWrappedAndName) SetArrayOfString(v []string)`

SetArrayOfString sets ArrayOfString field to given value.

### HasArrayOfString

`func (o *ArrayTestWithWrappedAndName) HasArrayOfString() bool`

HasArrayOfString returns a boolean if a field has been set.


[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading