Skip to content

Commit d6ef5b1

Browse files
committed
test(go): add test for RESOLVE_INLINE_ENUMS
1 parent f1a0935 commit d6ef5b1

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoClientCodegenTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,4 +396,25 @@ public void testAdditionalPropertiesWithoutGoMod() throws Exception {
396396
Path goSumFile = Paths.get(output + "/go.sum");
397397
TestUtils.assertFileNotExists(goSumFile);
398398
}
399+
400+
@Test
401+
public void testInlineEnums_issue9567() throws Exception {
402+
File output = Files.createTempDirectory("test").toFile();
403+
output.deleteOnExit();
404+
405+
final CodegenConfigurator configurator = new CodegenConfigurator()
406+
.setGeneratorName("go")
407+
.setInputSpec("src/test/resources/bugs/issue_9567.yaml")
408+
.setOutputDir(output.getAbsolutePath().replace("\\", "/"))
409+
.addInlineSchemaOption("RESOLVE_INLINE_ENUMS", "true")
410+
.addAdditionalProperty(GoClientCodegen.WITH_GO_MOD, false);
411+
412+
DefaultGenerator generator = new DefaultGenerator();
413+
List<File> files = generator.opts(configurator.toClientOptInput()).generate();
414+
System.out.println(files);
415+
files.forEach(File::deleteOnExit);
416+
417+
Path enumFile = Paths.get(output + "/model_pet_status.go");
418+
TestUtils.assertFileExists(enumFile);
419+
}
399420
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
openapi: 3.0.1
2+
info:
3+
title: TEST
4+
description: |-
5+
## TEST
6+
version: 1.0.0
7+
8+
servers:
9+
- url: /v3
10+
description: Major version of service
11+
12+
paths:
13+
/agreements:
14+
get:
15+
operationId: readAPet
16+
responses:
17+
"200":
18+
description: OK
19+
content:
20+
'*/*':
21+
schema:
22+
$ref: '#/components/schemas/Pet'
23+
components:
24+
schemas:
25+
Pet:
26+
title: a Pet
27+
description: A pet for sale in the pet store
28+
type: object
29+
properties:
30+
status:
31+
type: string
32+
description: pet status in the store
33+
enum:
34+
- available
35+
- pending
36+
- sold

0 commit comments

Comments
 (0)