Skip to content

Commit

Permalink
Fix inline resolver for open api generator (#1552)
Browse files Browse the repository at this point in the history
  • Loading branch information
altro3 authored Apr 25, 2024
1 parent 0fb9dc1 commit ed56347
Show file tree
Hide file tree
Showing 13 changed files with 513 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,11 @@ public String sanitizeTag(String tag) {
return tag;
}

@Override
public String toApiName(String name) {
return Utils.toApiName(name, apiNamePrefix, apiNameSuffix);
}

@Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co,
Map<String, List<CodegenOperation>> operations) {
Expand Down Expand Up @@ -732,7 +737,9 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
}

var inlineModelResolver = new MicronautInlineModelResolver(openAPI);
inlineModelResolver.flattenPaths();
inlineModelResolver.setInlineSchemaNameMapping(inlineSchemaNameMapping);
inlineModelResolver.setInlineSchemaOptions(inlineSchemaOption);
inlineModelResolver.flatten();

super.preprocessOpenAPI(openAPI);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import static org.openapitools.codegen.CodegenConstants.INVOKER_PACKAGE;
import static org.openapitools.codegen.languages.KotlinClientCodegen.DATE_LIBRARY;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;

/**
* Base generator for Micronaut.
Expand Down Expand Up @@ -675,6 +676,21 @@ public String sanitizeTag(String tag) {
return tag;
}

public String superSanitizeTag(String tag) {
tag = camelize(underscore(sanitizeName(tag)));

// tag starts with numbers
if (tag.matches("^\\d.*")) {
tag = "Class" + tag;
}
return tag;
}

@Override
public String toApiName(String name) {
return Utils.toApiName(name, apiNamePrefix, apiNameSuffix);
}

@Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co,
Map<String, List<CodegenOperation>> operations) {
Expand All @@ -683,7 +699,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
return;
}

super.addOperationToGroup(super.sanitizeTag(tag), resourcePath, operation, co, operations);
super.addOperationToGroup(superSanitizeTag(tag), resourcePath, operation, co, operations);
}

@Override
Expand Down Expand Up @@ -717,7 +733,9 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
}

var inlineModelResolver = new MicronautInlineModelResolver(openAPI);
inlineModelResolver.flattenPaths();
inlineModelResolver.setInlineSchemaNameMapping(inlineSchemaNameMapping);
inlineModelResolver.setInlineSchemaOptions(inlineSchemaOption);
inlineModelResolver.flatten();

super.preprocessOpenAPI(openAPI);
}
Expand Down
Loading

0 comments on commit ed56347

Please sign in to comment.