From 41093d70e0fadb6c686ed914a2a64af29985698f Mon Sep 17 00:00:00 2001 From: damien Date: Wed, 16 Oct 2024 22:51:27 +0200 Subject: [PATCH] #484 remove redundant subtype resolver - already handled by overrideInstanceAttributes --- .../MicroProfileOpenApi3AnyOfResolver.java | 44 ------------------- .../openapi3/MicroProfileOpenApi3Module.java | 1 - .../MicroProfileOpenApi3ModuleTest.java | 1 - 3 files changed, 46 deletions(-) delete mode 100644 jsonschema-module-microprofile-openapi-3/src/main/java/com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3AnyOfResolver.java diff --git a/jsonschema-module-microprofile-openapi-3/src/main/java/com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3AnyOfResolver.java b/jsonschema-module-microprofile-openapi-3/src/main/java/com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3AnyOfResolver.java deleted file mode 100644 index 30638167..00000000 --- a/jsonschema-module-microprofile-openapi-3/src/main/java/com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3AnyOfResolver.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2024 VicTools. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.github.victools.jsonschema.module.microprofile.openapi3; - -import com.fasterxml.classmate.ResolvedType; -import com.github.victools.jsonschema.generator.SchemaGenerationContext; -import com.github.victools.jsonschema.generator.SubtypeResolver; -import com.github.victools.jsonschema.generator.TypeContext; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.eclipse.microprofile.openapi.annotations.media.Schema; - -/** - * Subtype resolver considering {@code @Schema(anyOf = ...)}. - */ -public class MicroProfileOpenApi3AnyOfResolver implements SubtypeResolver { - - @Override - public List findSubtypes(ResolvedType declaredType, SchemaGenerationContext context) { - Schema annotation = declaredType.getErasedType().getAnnotation(Schema.class); - if (annotation == null || annotation.anyOf().length == 0) { - return null; - } - TypeContext typeContext = context.getTypeContext(); - return Stream.of(annotation.anyOf()) - .map(typeContext::resolve) - .collect(Collectors.toList()); - } -} diff --git a/jsonschema-module-microprofile-openapi-3/src/main/java/com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java b/jsonschema-module-microprofile-openapi-3/src/main/java/com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java index 8bcc8359..0b9d1f52 100644 --- a/jsonschema-module-microprofile-openapi-3/src/main/java/com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java +++ b/jsonschema-module-microprofile-openapi-3/src/main/java/com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3Module.java @@ -64,7 +64,6 @@ private void applyToConfigBuilder(SchemaGeneratorGeneralConfigPart configPart) { configPart.withAdditionalPropertiesResolver(this.createTypePropertyResolver(this::mapAdditionalPropertiesEnumValue, Objects::nonNull)); configPart.withCustomDefinitionProvider(new ExternalRefCustomDefinitionProvider()); - configPart.withSubtypeResolver(new MicroProfileOpenApi3AnyOfResolver()); configPart.withDefinitionNamingStrategy(new MicroProfileOpenApi3SchemaDefinitionNamingStrategy(configPart.getDefinitionNamingStrategy())); } diff --git a/jsonschema-module-microprofile-openapi-3/src/test/java/com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3ModuleTest.java b/jsonschema-module-microprofile-openapi-3/src/test/java/com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3ModuleTest.java index 6a90420e..1e2b3a00 100644 --- a/jsonschema-module-microprofile-openapi-3/src/test/java/com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3ModuleTest.java +++ b/jsonschema-module-microprofile-openapi-3/src/test/java/com/github/victools/jsonschema/module/microprofile/openapi3/MicroProfileOpenApi3ModuleTest.java @@ -69,7 +69,6 @@ public void testApplyToConfigBuilder() { Mockito.verify(this.typesInGeneralConfigPart).withAdditionalPropertiesResolver(Mockito.any(ConfigFunction.class)); Mockito.verify(this.typesInGeneralConfigPart).withAdditionalPropertiesResolver(Mockito.any(BiFunction.class)); Mockito.verify(this.typesInGeneralConfigPart).withCustomDefinitionProvider(Mockito.any(ExternalRefCustomDefinitionProvider.class)); - Mockito.verify(this.typesInGeneralConfigPart).withSubtypeResolver(Mockito.any(MicroProfileOpenApi3AnyOfResolver.class)); Mockito.verify(this.typesInGeneralConfigPart).getDefinitionNamingStrategy(); Mockito.verify(this.typesInGeneralConfigPart).withDefinitionNamingStrategy(Mockito.any(MicroProfileOpenApi3SchemaDefinitionNamingStrategy.class));