Skip to content
Merged
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 @@ -892,7 +892,7 @@ public List<File> generate() {

sb.append(System.lineSeparator());

System.err.println(sb.toString());
LOGGER.error(sb.toString());
} else {
// This exists here rather than in the method which generates supporting files to avoid accidentally adding files after this metadata.
if (generateSupportingFiles) {
Expand Down Expand Up @@ -924,6 +924,10 @@ protected File processTemplateToFile(Map<String, Object> templateData, String te

public Map<String, List<CodegenOperation>> processPaths(Paths paths) {
Map<String, List<CodegenOperation>> ops = new TreeMap<>();
// when input file is not valid and doesn't contain any paths
if(paths == null) {
return ops;
}
for (String resourcePath : paths.keySet()) {
PathItem path = paths.get(resourcePath);
processOperation(resourcePath, "get", path.getGet(), ops, path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.openapitools.codegen.MockDefaultGenerator.WrittenTemplateBasedFile;
import org.openapitools.codegen.config.CodegenConfigurator;
import org.openapitools.codegen.languages.AbstractJavaCodegen;
import org.openapitools.codegen.languages.DartClientCodegen;
import org.openapitools.codegen.languages.JavaClientCodegen;
import org.testng.Assert;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -507,6 +508,34 @@ public void testAuthorizationScopeValues_Issue392() {
assertEquals(postScopes.size(), 2, "POST scopes don't match. actual:" + postScopes);
}

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

final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("java")
.setLibrary(JavaClientCodegen.RESTEASY)
.setValidateSpec(false)
.setInputSpec("src/test/resources/3_0/regression-6734.yaml")
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));

final ClientOptInput clientOptInput = configurator.toClientOptInput();

DefaultGenerator generator = new DefaultGenerator();
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
// tests if NPE will crash generation when path in yaml arent provided
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
generator.setGenerateMetadata(false);
List<File> files = generator.opts(clientOptInput).generate();

Assert.assertEquals(files.size(), 1);
files.forEach(File::deleteOnExit);
}

@Test
public void testAuthorizationsHasMoreWhenFiltered() {
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue4584.yaml");
Expand Down Expand Up @@ -574,6 +603,7 @@ public void testImportMapping() throws IOException {
importMappings.put("TypeAlias", "foo.bar.TypeAlias");

File output = Files.createTempDirectory("test").toFile();
output.deleteOnExit();

final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("java")
Expand All @@ -594,6 +624,7 @@ public void testImportMapping() throws IOException {
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
generator.setGenerateMetadata(false);
List<File> files = generator.opts(clientOptInput).generate();
files.forEach(File::deleteOnExit);

Assert.assertEquals(files.size(), 1);
TestUtils.ensureContainsFile(files, output, "src/main/java/org/openapitools/client/model/ParentType.java");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
openapi: 3.0.0
info:
version: 1.0.0
title: Whatever this is
description: whatever this description is

servers:
- url: http://127.0.0.1:8080/{basePath}
variables:
basePath:
default: v1

components:
schemas:
MyModel:
type: object
description: Description of a model
properties:
sortOrder:
type: string
enum: [asc, desc]