Skip to content

Commit

Permalink
fix(openapi): misc fixes to OpenAPI generator
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Jul 24, 2024
1 parent 1545ba2 commit 2b84855
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ private static Map<String, ApiVersion> computeApiVersions(OpenAPI openAPI) {
for (Operation operation : new Operation[] { apiPath.getValue().getGet(), apiPath.getValue().getPost() }) {
if (operation == null
|| operation.getResponses().get("200") == null
|| operation.getResponses().get("200").getContent().get(APPLICATION_JSON) == null) {
|| operation.getResponses().get("200").getContent().get(APPLICATION_JSON) == null
|| operation.getExtensions() == null
|| operation.getExtensions().get("x-kubernetes-group-version-kind") == null) {
continue;
}
final ApiVersion.ApiVersionBuilder apiVersionBuilder = ApiVersion.builder();
Expand All @@ -196,9 +198,6 @@ private static Map<String, ApiVersion> computeApiVersions(OpenAPI openAPI) {
// } else {
// apiVersionBuilder.group("").version("v1");
// }
if (operation.getExtensions() == null || operation.getExtensions().get("x-kubernetes-group-version-kind") == null) {
continue;
}
final Map<String, String> groupVersionKind = (Map<String, String>) operation.getExtensions()
.get("x-kubernetes-group-version-kind");
apiVersionBuilder.group(groupVersionKind.get("group"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ private String resolveImplementedInterfaces(TemplateContext templateContext) {
private Map<String, List<String>> buildableReferences(TemplateContext templateContext, List<Map<String, Object>> fields) {
final List<String> references = new ArrayList<>(settings.getBuildableReferences());
references.add(0, settings.getObjectMetaClass());
if (fields.stream().map(f -> f.get("type")).map(Object::toString)
if (fields.stream().map(f -> f.get("type")).filter(Objects::nonNull).map(Object::toString)
.anyMatch(r -> r.contains("KubernetesResource") || r.contains("HasMetadata") || r.contains("RawExtension"))) {
references.add(settings.getGenericKubernetesResourceClass());
references.add(settings.getRawExtensionClass());
Expand Down

0 comments on commit 2b84855

Please sign in to comment.