File tree Expand file tree Collapse file tree
modules/openapi-generator/src
main/java/org/openapitools/codegen/languages
test/java/org/openapitools/codegen/go Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -800,6 +800,9 @@ public ModelsMap postProcessModels(ModelsMap objs) {
800800
801801 if (withXml ) {
802802 goDataTag += " xml:" + "\" " + cp .baseName ;
803+ if (cp .isXmlWrapped ) {
804+ goDataTag += ">" + ("" .equals (cp .xmlName ) ? cp .baseName : cp .xmlName );
805+ }
803806 if (cp .isXmlAttribute ) {
804807 goDataTag += ",attr" ;
805808 }
Original file line number Diff line number Diff line change @@ -396,4 +396,26 @@ public void testAdditionalPropertiesWithoutGoMod() throws Exception {
396396 Path goSumFile = Paths .get (output + "/go.sum" );
397397 TestUtils .assertFileNotExists (goSumFile );
398398 }
399+
400+ @ Test
401+ public void testXmlOptionsBeingUsed () throws IOException {
402+ Map <String , Object > properties = new HashMap <>();
403+ properties .put (GoClientCodegen .STRUCT_PREFIX , true );
404+ properties .put (GoClientCodegen .WITH_XML , true );
405+
406+ File output = Files .createTempDirectory ("test" ).toFile ();
407+ output .deleteOnExit ();
408+
409+ final CodegenConfigurator configurator = new CodegenConfigurator ()
410+ .setGeneratorName ("go" )
411+ .setAdditionalProperties (properties )
412+ .setInputSpec ("src/test/resources/3_0/petstore.yaml" )
413+ .setOutputDir (output .getAbsolutePath ().replace ("\\ " , "/" ));
414+
415+ DefaultGenerator generator = new DefaultGenerator ();
416+ List <File > files = generator .opts (configurator .toClientOptInput ()).generate ();
417+ files .forEach (File ::deleteOnExit );
418+
419+ TestUtils .assertFileContains (Paths .get (output + "/model_pet.go" ), "tags>tag" );
420+ }
399421}
You can’t perform that action at this time.
0 commit comments