diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/configuration/properties/SpringwolfConfigProperties.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/configuration/properties/SpringwolfConfigProperties.java index 6f5f6d855..677e5e362 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/configuration/properties/SpringwolfConfigProperties.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/configuration/properties/SpringwolfConfigProperties.java @@ -59,8 +59,7 @@ public enum InitMode { @Nullable private Endpoint endpoint; - @Nullable - private ConfigDocket docket; + private ConfigDocket docket = new ConfigDocket(); @Nullable private Scanner scanner; diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/schemas/example/DefaultSchemaWalker.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/schemas/example/DefaultSchemaWalker.java index 368913c50..d6baddee4 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/schemas/example/DefaultSchemaWalker.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/schemas/example/DefaultSchemaWalker.java @@ -18,12 +18,7 @@ import static io.github.stavshamir.springwolf.configuration.properties.SpringwolfConfigConstants.SPRINGWOLF_SCHEMA_EXAMPLE_GENERATOR; -// TODO: Example JsonGenerator: Traversieren vom Generieren Trennen -// TODO: Welche API brauchen wir beim Generieren? Parentmitgeben vs State im Generator - // TODO: Einfach Yaml generieren? -// TODO: Wie wird der XML Root richtig gesetzt? - @Slf4j @ConditionalOnProperty(name = SPRINGWOLF_SCHEMA_EXAMPLE_GENERATOR, havingValue = "buildin-json", matchIfMissing = true) @RequiredArgsConstructor @@ -171,7 +166,7 @@ private String getFirstEnumValue(Schema schema) { if (enums != null) { Optional firstEnumEntry = enums.stream().findFirst(); if (firstEnumEntry.isPresent()) { - return firstEnumEntry.get(); // TODO: Pass through example value generator + return firstEnumEntry.get(); } } return null; @@ -192,7 +187,6 @@ private T handleObject(String name, Schema schema, Map definitio if (schema.getAllOf() != null && !schema.getAllOf().isEmpty()) { List schemas = schema.getAllOf(); - // TODO lookup ref? Schema allOfSchema = schemas.get(0); // Open: Handle properties of all schemas, not only the first one return buildSchemaInternal(name, allOfSchema, definitions, visited); diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AsyncAnnotationScannerUtilTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AsyncAnnotationScannerUtilTest.java index 44675ba7b..dfe18ba6d 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AsyncAnnotationScannerUtilTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AsyncAnnotationScannerUtilTest.java @@ -159,6 +159,7 @@ void processMessageFromAnnotationWithAsyncMessage(Class classWithOperationBin .messageId("simpleFoo") .name("SimpleFooPayLoad") .title("Message Title") + .contentType("application/schema+json;version=draft-07") .build(); assertEquals(expectedMessage, actual.build()); } diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/DefaultJsonSchemasServiceTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/DefaultJsonSchemasServiceTest.java index 635383a96..0a941c5bf 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/DefaultJsonSchemasServiceTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/DefaultJsonSchemasServiceTest.java @@ -9,7 +9,6 @@ import io.github.stavshamir.springwolf.asyncapi.scanners.channels.payload.AsyncApiPayload; import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageObject; import io.github.stavshamir.springwolf.configuration.properties.SpringwolfConfigProperties; -import io.github.stavshamir.springwolf.configuration.properties.SpringwolfConfigProperties.ConfigDocket; import io.github.stavshamir.springwolf.schemas.example.DefaultSchemaWalker; import io.github.stavshamir.springwolf.schemas.example.ExampleJsonValueGenerator; import io.github.stavshamir.springwolf.schemas.example.SchemaWalkerProvider; @@ -20,7 +19,6 @@ import jakarta.annotation.Nullable; import lombok.Data; import lombok.NoArgsConstructor; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -44,28 +42,20 @@ class DefaultJsonSchemasServiceTest { private final SchemasPostProcessor schemasPostProcessor = Mockito.mock(SchemasPostProcessor.class); - private ComponentsService componentsService; + private final ComponentsService componentsService = new DefaultComponentsService( + List.of(), + List.of( + new ExampleGeneratorPostProcessor(new SchemaWalkerProvider( + List.of(new DefaultSchemaWalker<>(new ExampleJsonValueGenerator())))), + schemasPostProcessor), + new SwaggerSchemaUtil(), + new SpringwolfConfigProperties()); private static final ObjectMapper objectMapper = Json.mapper().enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); private static final PrettyPrinter printer = new DefaultPrettyPrinter().withObjectIndenter(new DefaultIndenter(" ", DefaultIndenter.SYS_LF)); - @BeforeEach - void setUp() { - SpringwolfConfigProperties configProperties = new SpringwolfConfigProperties(); - configProperties.setDocket(new ConfigDocket()); - - componentsService = new DefaultComponentsService( - List.of(), - List.of( - new ExampleGeneratorPostProcessor(new SchemaWalkerProvider( - List.of(new DefaultSchemaWalker<>(new ExampleJsonValueGenerator())))), - schemasPostProcessor), - new SwaggerSchemaUtil(), - configProperties); - } - @Test void getSchemas() throws IOException { componentsService.registerSchema(CompositeFoo.class); @@ -157,7 +147,6 @@ void classWithSchemaAnnotation() { void getDefinitionWithFqnClassName() throws IOException { // given SpringwolfConfigProperties properties = new SpringwolfConfigProperties(); - properties.setDocket(new ConfigDocket()); properties.setUseFqn(true); ComponentsService componentsServiceWithFqn = diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/DefaultXmlSchemasServiceTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/DefaultXmlSchemasServiceTest.java index 8c2f80e42..17f268ad4 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/DefaultXmlSchemasServiceTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/DefaultXmlSchemasServiceTest.java @@ -344,7 +344,6 @@ public class ImplementationTwo { class AsyncApiPayloadTest { @Test void stringEnvelopTest() throws IOException { - // TODO fix me componentsService.registerSchema(StringEnvelop.class, "text/xml"); String actualDefinitions = objectMapper.writer(printer).writeValueAsString(componentsService.getSchemas()); diff --git a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/example/DefaultSchemaWalkerXmlIntegrationTest.java b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/example/DefaultSchemaWalkerXmlIntegrationTest.java index cc381f2da..192d00bae 100644 --- a/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/example/DefaultSchemaWalkerXmlIntegrationTest.java +++ b/springwolf-core/src/test/java/io/github/stavshamir/springwolf/schemas/example/DefaultSchemaWalkerXmlIntegrationTest.java @@ -1,7 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 package io.github.stavshamir.springwolf.schemas.example; -import com.fasterxml.jackson.core.JsonProcessingException; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.BinarySchema; import io.swagger.v3.oas.models.media.BooleanSchema; @@ -66,7 +65,7 @@ void shouldNotHandleOtherContentType() { class FromSchema { @Test - void build() throws JsonProcessingException { + void build() { StringSchema schema = new StringSchema(); schema.setName("build_schema_test"); // TODO should throw exception, just a raw value does not work in xml @@ -340,7 +339,9 @@ void type_object_array() { String actual = xmlSchemaWalker.fromSchema(schema, emptyMap()).trim(); assertThat(actual) - .isEqualTo("truestring".trim().stripIndent()); + .isEqualTo("truestring" + .trim() + .stripIndent()); } @Test @@ -385,9 +386,10 @@ void composite_object_without_references() { xmlSchemaWalker.fromSchema(schema, emptyMap()).trim().stripIndent(); assertThat(actual) - .isEqualTo("truestring" - .trim() - .stripIndent()); + .isEqualTo( + "truestring" + .trim() + .stripIndent()); } @Test @@ -411,9 +413,10 @@ void composite_object_with_references() { .stripIndent(); assertThat(actual) - .isEqualTo("truestringstring" - .trim() - .stripIndent()); + .isEqualTo( + "truestringstring" + .trim() + .stripIndent()); } @Test