Skip to content
Open
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 @@ -375,6 +375,32 @@ public void testAdditionalPropertiesWithGoMod() throws Exception {
TestUtils.assertFileExists(goSumFile);
}

@Test
public void testAdditionalPropertiesPrefixEnums() throws Exception {
File output = Files.createTempDirectory("test").toFile();
output.deleteOnExit();

final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("go")
.setInputSpec("src/test/resources/3_1/enum_collision.yaml")
.setOutputDir(output.getAbsolutePath().replace("\\", "/"))
.addAdditionalProperty("enumClassPrefix", "true")
.addInlineSchemaOption("RESOLVE_INLINE_ENUMS", "true");

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

Path petFile = Paths.get(output + "/model_pet_status.go");
TestUtils.assertFileExists(petFile);
TestUtils.assertFileContains(petFile, "PETSTATUS_SOLD");

Path machineFile = Paths.get(output + "/model_machine_status.go");
TestUtils.assertFileExists(machineFile);
TestUtils.assertFileContains(machineFile, "MACHINESTATUS_SOLD");
}

@Test
public void testAdditionalPropertiesWithoutGoMod() throws Exception {
File output = Files.createTempDirectory("test").toFile();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
openapi: 3.1.0
info:
title: TEST
description: |-
## TEST
version: 1.0.0

servers:
- url: /v3
description: Major version of service

paths:
/agreements:
get:
operationId: readAPet
responses:
"200":
description: OK
content:
'*/*':
schema:
$ref: '#/components/schemas/Pet'
components:
schemas:
Pet:
title: a Pet
description: A pet for sale in the pet store
type: object
properties:
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
Machine:
title: a Machine
description: A machine for sale in the pet store
type: object
properties:
status:
type: string
description: machine status in the store
enum:
- available
- pending
- sold
Loading