forked from loafle/openapi-generator-original
fixed bug where nullApi.java would be generated. Instead, generated DefaultApi.java to match the default path /{pathParam} (#3821)
This commit is contained in:
parent
2a2eefe93d
commit
ec7f2a0450
@ -239,6 +239,9 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
public String toApiName(final String name) {
|
||||
String computed = name;
|
||||
if (computed.length() == 0) {
|
||||
if (primaryResourceName == null) {
|
||||
return "DefaultApi";
|
||||
}
|
||||
return primaryResourceName + "Api";
|
||||
}
|
||||
computed = sanitizeName(computed);
|
||||
|
@ -286,4 +286,30 @@ public class JavaJAXRSSpecServerCodegenTest extends JavaJaxrsBaseTest {
|
||||
|
||||
output.deleteOnExit();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenerateApiWithPreceedingPathParameter_issue1347() throws Exception {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put(JavaClientCodegen.JAVA8_MODE, true);
|
||||
properties.put(JavaJAXRSSpecServerCodegen.OPEN_API_SPEC_FILE_LOCATION, "openapi.yml");
|
||||
|
||||
File output = Files.createTempDirectory("test").toFile();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setGeneratorName("jaxrs-spec")
|
||||
.setAdditionalProperties(properties)
|
||||
.setInputSpec("src/test/resources/3_0/issue_1347.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
MockDefaultGenerator generator = new MockDefaultGenerator();
|
||||
generator.opts(clientOptInput).generate();
|
||||
|
||||
Map<String, String> generatedFiles = generator.getFiles();
|
||||
validateJavaSourceFiles(generatedFiles);
|
||||
TestUtils.ensureContainsFile(generatedFiles, output, "openapi.yml");
|
||||
TestUtils.ensureContainsFile(generatedFiles, output, "src/gen/java/org/openapitools/api/DefaultApi.java");
|
||||
|
||||
output.deleteOnExit();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
openapi: 3.0.2
|
||||
info:
|
||||
title: Name demo
|
||||
version: 1.0
|
||||
paths:
|
||||
/{country}/document:
|
||||
get:
|
||||
summary: Get a document
|
||||
tags:
|
||||
- document
|
||||
operationId: getDocument
|
||||
parameters:
|
||||
- name: country
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"201":
|
||||
description: The document
|
||||
"500":
|
||||
description: Server error
|
||||
tags:
|
||||
- name: document
|
||||
description: Document tag
|
Loading…
x
Reference in New Issue
Block a user