forked from loafle/openapi-generator-original
* bump swagger-parser-version to v2.0.26 * add tests for #9086
This commit is contained in:
parent
c2cc7a02aa
commit
9099b43cd8
@ -17,6 +17,7 @@
|
||||
|
||||
package org.openapitools.codegen.yaml;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import org.openapitools.codegen.ClientOptInput;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
import org.openapitools.codegen.TestUtils;
|
||||
@ -85,4 +86,36 @@ public class YamlGeneratorTest {
|
||||
|
||||
output.deleteOnExit();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIssue9086() throws Exception {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put(OpenAPIYamlGenerator.OUTPUT_NAME, "issue_9086.yaml");
|
||||
|
||||
File output = Files.createTempDirectory("issue_9086").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
.setGeneratorName("openapi-yaml")
|
||||
.setAdditionalProperties(properties)
|
||||
.setInputSpec("src/test/resources/2_0/issue_9086.yaml")
|
||||
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||
|
||||
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
List<File> files = generator.opts(clientOptInput).generate();
|
||||
Assert.assertEquals(files.size(), 5);
|
||||
TestUtils.ensureContainsFile(files, output, "issue_9086.yaml");
|
||||
|
||||
TestUtils.ensureContainsFile(files, output, "README.md");
|
||||
TestUtils.ensureContainsFile(files, output, ".openapi-generator-ignore");
|
||||
TestUtils.ensureContainsFile(files, output, ".openapi-generator/FILES");
|
||||
TestUtils.ensureContainsFile(files, output, ".openapi-generator/VERSION");
|
||||
|
||||
OpenAPI generated = TestUtils.parseSpec(new File(output, "issue_9086.yaml").getPath());
|
||||
OpenAPI expected = TestUtils.parseSpec("src/test/resources/2_0/issue_9086_expected.yaml");
|
||||
|
||||
// use #toString because the equals methods is a little stricter than necessary for this test
|
||||
Assert.assertEquals(expected.toString(), generated.toString());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
swagger: '2.0'
|
||||
info:
|
||||
title: 'Buggy Api'
|
||||
version: '1.0'
|
||||
consumes:
|
||||
- application/json
|
||||
paths:
|
||||
/foo/bar:
|
||||
post:
|
||||
responses:
|
||||
'200':
|
||||
description: ok
|
||||
schema:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
properties:
|
||||
n:
|
||||
type: number
|
||||
example: 1.23
|
||||
/foo/bar2:
|
||||
post:
|
||||
responses:
|
||||
'200':
|
||||
description: ok
|
||||
schema:
|
||||
$ref: '#/definitions/bar2'
|
||||
definitions:
|
||||
bar2:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
properties:
|
||||
n:
|
||||
type: number
|
||||
example: 4.56
|
@ -0,0 +1,40 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: 'Buggy Api'
|
||||
version: '1.0'
|
||||
paths:
|
||||
/foo/bar:
|
||||
post:
|
||||
responses:
|
||||
'200':
|
||||
description: ok
|
||||
content:
|
||||
'*/*':
|
||||
schema:
|
||||
$ref: '#/components/schemas/inline_response_200'
|
||||
|
||||
/foo/bar2:
|
||||
post:
|
||||
responses:
|
||||
'200':
|
||||
description: ok
|
||||
content:
|
||||
'*/*':
|
||||
schema:
|
||||
$ref: '#/components/schemas/bar2'
|
||||
components:
|
||||
schemas:
|
||||
bar2:
|
||||
type: object
|
||||
example: { n: 4.56 }
|
||||
properties:
|
||||
n:
|
||||
type: number
|
||||
example: 4.56
|
||||
inline_response_200:
|
||||
type: object
|
||||
example: { n: 1.23 }
|
||||
properties:
|
||||
n:
|
||||
type: number
|
||||
example: 1.23
|
2
pom.xml
2
pom.xml
@ -1576,7 +1576,7 @@
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<swagger-core-version>2.1.2</swagger-core-version>
|
||||
<swagger-parser-groupid>io.swagger.parser.v3</swagger-parser-groupid>
|
||||
<swagger-parser-version>2.0.24</swagger-parser-version>
|
||||
<swagger-parser-version>2.0.26</swagger-parser-version>
|
||||
<felix-version>3.3.1</felix-version>
|
||||
<commons-io-version>2.4</commons-io-version>
|
||||
<commons-cli-version>1.2</commons-cli-version>
|
||||
|
Loading…
x
Reference in New Issue
Block a user