Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
9 changes: 9 additions & 0 deletions .github/workflows/springwolf-addons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ jobs:
- name: Run build, check, analyzeDependencies on add-on
run: ./gradlew -p ${{ env.addon }} build

- name: Publish Test Report
uses: mikepenz/action-junit-report@v6
if: success() || failure()
with:
check_name: test-addon-${{ matrix.addon }}
require_tests: true
report_paths: '**/build/test-results/test/TEST-*.xml'
annotate_only: github.event.pull_request.head.repo.full_name != github.repository # for forks

- name: Publish package
if: github.ref == 'refs/heads/main'
run: ./gradlew -p ${{ env.addon }} publish
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/springwolf-asyncapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ jobs:
- name: Build with Gradle
run: ./gradlew -p springwolf-asyncapi build

- name: Publish Test Report
uses: mikepenz/action-junit-report@v6
if: success() || failure()
with:
check_name: test-asyncapi
require_tests: true
report_paths: '**/build/test-results/test/TEST-*.xml'
annotate_only: github.event.pull_request.head.repo.full_name != github.repository # for forks

- name: Publish package
if: github.ref == 'refs/heads/main'
run: ./gradlew -p springwolf-asyncapi publish
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/springwolf-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ jobs:
- name: Run build, check, analyzeDependencies on bindings
run: ./gradlew -p springwolf-bindings build

- name: Publish Test Report
uses: mikepenz/action-junit-report@v6
if: success() || failure()
with:
check_name: test-bindings
require_tests: true
report_paths: '**/build/test-results/test/TEST-*.xml'
annotate_only: github.event.pull_request.head.repo.full_name != github.repository # for forks

- name: Publish package
if: github.ref == 'refs/heads/main'
run: ./gradlew -p springwolf-bindings publish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Sometimes adding documentation annotation is not possible on classes, i.e. they are marked as final or are from external libraries.
* This converter allows to add documentation to such classes. Duplicate the _target_ class as _native_ into your project and add documentation annotations.
* Then, create an instance (@Bean, @Component) of this converter in your configuration mapping the classes.
*
* <p/>
* Example: {@link io.github.springwolf.addons.common_model_converters.converters.monetaryamount.MonetaryAmountConverter}
*/
public class SimpleClassModelConverter implements ModelConverter {
Expand All @@ -28,7 +28,7 @@ public SimpleClassModelConverter(Class<?> targetClass, Class<?> nativeClass) {
}

@Override
public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) {
public Schema<?> resolve(AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) {
Class<?> rawClass = getRawClass(type);
boolean isNativeType = isNativeType(rawClass);

Expand All @@ -50,7 +50,8 @@ private Class<?> getRawClass(AnnotatedType type) {
return javaType != null ? javaType.getRawClass() : null;
}

private Schema proceedWithChain(AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) {
private Schema<?> proceedWithChain(
AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) {
return (chain.hasNext()) ? chain.next().resolve(type, context, chain) : null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
import java.util.Iterator;

/**
* Workaround for https://github.com/swagger-api/swagger-core/pull/4727
* Workaround for <a href="https://github.com/swagger-api/swagger-core/pull/4727">swagger-core PR 4727</a>
*/
public class NameInReffedSchemaModelConverter implements ModelConverter {

@Override
public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) {
public Schema<?> resolve(AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) {
JavaType javaType = Json.mapper().constructType(type.getType());
if (chain.hasNext()) {
Schema<?> schema = chain.next().resolve(type, context, chain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ void nameIsAddedToReffedSchema() {
converters.addConverter(modelsConverter);

// when
final Map<String, Schema> models = converters.readAll(MyRootObject.class);
final Map<String, ?> models = converters.readAll(MyRootObject.class);

// then
assertThat(models).isNotNull();
assertThat(models.size()).isEqualTo(2);
Schema myRootObject = models.get("MyRootObject");
Schema<?> myRootObject = (Schema<?>) models.get("MyRootObject");
assertThat(myRootObject).isNotNull();
assertThat(myRootObject.getName()).isEqualTo("MyRootObject");
Schema myEnumObjectField = (Schema) myRootObject.getProperties().get("myEnumObjectField");
Schema<?> myEnumObjectField = (Schema<?>) myRootObject.getProperties().get("myEnumObjectField");
assertThat(myEnumObjectField.getName()).isEqualTo("myEnumObjectField");
assertThat(myEnumObjectField.get$ref()).isEqualTo("#/components/schemas/MyEnumObject");

Schema myEnumObject = models.get("MyEnumObject");
Schema<?> myEnumObject = (Schema<?>) models.get("MyEnumObject");
assertThat(myEnumObject).isNotNull();
assertThat(myEnumObject.getName()).isEqualTo("MyEnumObject");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ void monetaryAmountConverter() {
converters.addConverter(modelsConverter);

// when
final Map<String, Schema> models = converters.readAll(new AnnotatedType(javax.money.MonetaryAmount.class));
final Map<String, ?> models = converters.readAll(new AnnotatedType(javax.money.MonetaryAmount.class));

// then
final Schema model = models.get("MonetaryAmount");
final Schema<?> model = (Schema<?>) models.get("MonetaryAmount");
assertThat(model).isNotNull();

assertThat(model.getProperties().size()).isEqualTo(2);

final Schema amountProperty = (Schema) model.getProperties().get("amount");
final Schema<?> amountProperty = (Schema<?>) model.getProperties().get("amount");
assertThat(amountProperty).isNotNull();

final Schema currencyProperty = (Schema) model.getProperties().get("currency");
final Schema<?> currencyProperty = (Schema<?>) model.getProperties().get("currency");
assertThat(currencyProperty).isNotNull();

final Schema missingProperty = (Schema) model.getProperties().get("missing");
final Schema<?> missingProperty = (Schema<?>) model.getProperties().get("missing");
assertThat(missingProperty).isNull();

// then
final Schema originalModel = models.get("javax.money.MonetaryAmount");
final Schema<?> originalModel = (Schema<?>) models.get("javax.money.MonetaryAmount");
assertThat(originalModel).isNotNull();

assertThat(originalModel.getType()).isNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void handleEmptySchemaTest() {
}

@Test
void shouldAddJsonSchemaExtensionTest() throws Exception {
void shouldAddJsonSchemaExtensionTest() {
// given
AsyncAPI asyncAPI = createAsyncApi();
SchemaObject schemaObject = new SchemaObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.github.springwolf.asyncapi.v3.model.schema.SchemaObject;
import io.github.springwolf.asyncapi.v3.model.schema.SchemaReference;
import io.github.springwolf.asyncapi.v3.model.schema.SchemaType;
import io.github.springwolf.core.asyncapi.schemas.SwaggerSchemaMapper;
import io.github.springwolf.core.asyncapi.schemas.schema.SwaggerSchemaMapper;
import io.github.springwolf.core.configuration.properties.SpringwolfConfigProperties;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.BooleanSchema;
Expand Down Expand Up @@ -46,7 +46,7 @@ class JsonSchemaGeneratorTest {

@ParameterizedTest
@MethodSource
void validateJsonSchemaTest(String expectedJsonSchema, Supplier<Schema<?>> asyncApiSchema) throws Exception {
void validateJsonSchemaTest(String expectedJsonSchema, Supplier<Schema<?>> asyncApiSchema) {
// given
ComponentSchema actualSchema = swaggerSchemaMapper.mapSchema(asyncApiSchema.get());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class JMSServerBinding extends ServerBinding {
/**
* OPTIONAL. Additional properties to set on the JMS ConnectionFactory implementation for the JMS Provider.
*/
// FIXME: See https://github.com/asyncapi/bindings/issues/232
// Bug report, see https://github.com/asyncapi/bindings/issues/232
@JsonProperty("properties")
private List<Map<String, Object>> properties;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class AsyncAPI extends ExtendableObject {
/**
* REQUIRED. Specifies the AsyncAPI Specification version being used. It can be used by tooling Specifications and
* clients to interpret the version. The structure shall be major.minor.patch, where patch versions must be
* compatible with the existing major.minor tooling. Typically patch versions will be introduced to address errors
* compatible with the existing major.minor tooling. Typically, patch versions will be introduced to address errors
* in the documentation, and tooling should typically be compatible with the corresponding major.minor (1.0.*).
* Patch versions will correspond to patches of this document.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
/**
* Container class representing a schema in the 'components' block of an AsyncAPI document. Contains either
* <ul>
* <li>a {@link SchemaObject} instance, which represents an schema formatted with the default asyncapi schema format</li>
* <li>a {@link SchemaReference}} instance, pointing to an other schema </li>
* <li>a {@link MultiFormatSchema} instance, which includes a schema an a corresponding schema format </li>
* <li>a {@link SchemaObject} instance, which represents a schema formatted with the default asyncapi schema format</li>
* <li>a {@link SchemaReference}} instance, pointing to another schema </li>
* <li>a {@link MultiFormatSchema} instance, which includes a schema and a corresponding schema format </li>
* </ul>
* Json Serialization removes this container class and serializes the content Object directly.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void shouldSerializeJMSChannel() throws Exception {
.isEqualTo(example);
}

// FIXME: See https://github.com/asyncapi/bindings/issues/232
// Bug report, see https://github.com/asyncapi/bindings/issues/232
@Test
void shouldSerializeJMSServerBinding() throws Exception {
var asyncapi = AsyncAPI.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ private AsyncAPI getAsyncAPITestObject(SchemaFormat schemaFormat) {
.bindings(Map.of(
"kafka",
KafkaMessageBinding.builder()
// FIXME: We should have a SchemaString (Schema<String>)
.key(SchemaObject.builder()
.type(Set.of(SchemaType.STRING.getValue()))
.build())
Expand Down Expand Up @@ -150,8 +149,10 @@ private Map<String, ComponentSchema> createPayloadSchema(SchemaFormat schemaForm
void AsyncAPI_should_map_to_a_valid_asyncapi_json(SchemaFormat schemaFormat, String expectedFile) throws Exception {
AsyncAPI asyncapi = getAsyncAPITestObject(schemaFormat);
String actual = serializer.toJsonString(asyncapi);
InputStream s = this.getClass().getResourceAsStream(expectedFile + ".json");
String expected = new String(s.readAllBytes(), StandardCharsets.UTF_8);
String expected;
try (InputStream s = this.getClass().getResourceAsStream(expectedFile + ".json")) {
expected = new String(s.readAllBytes(), StandardCharsets.UTF_8);
}
assertThatJson(actual).isEqualTo(expected);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,4 @@ void shouldCreateStreetlightsKafkaAsyncAPI() throws Exception {
.whenIgnoringPaths("components.operationTraits.kafka.bindings.kafka.bindingVersion")
.isEqualTo(example);
}

// FIXME: We should have the capability to serialize automatically creating the $ref values with the proper keys
// Current approach forces the developer to manually create the structure, which is limiting
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void shouldSerializeOperation() throws Exception {

String example = ClasspathUtil.readAsString("/v3/model/operation/operation.json");
assertThatJson(serializer.toJsonString(operation))
// FIXME: https://github.com/asyncapi/spec/issues/1007
// Bug report, see https://github.com/asyncapi/spec/issues/1007
.whenIgnoringPaths("bindings.amqp.bindingVersion", "bindings.amqp.expiration", "security")
.isEqualTo(example);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SchemaTest {
private static final DefaultAsyncApiSerializerService serializer = new DefaultAsyncApiSerializerService();

@Test
void shouldSerializePrimitiveSample() throws Exception {
void shouldSerializePrimitiveSample() {
var schema = SchemaObject.builder()
.type(Set.of(SchemaType.STRING.getValue()))
.format("email")
Expand All @@ -32,7 +32,7 @@ void shouldSerializePrimitiveSample() throws Exception {
}

@Test
void shouldSerializeSimpleModel() throws Exception {
void shouldSerializeSimpleModel() {
var schema = SchemaObject.builder()
.type(Set.of(SchemaType.OBJECT.getValue()))
.required(List.of("name"))
Expand Down Expand Up @@ -75,7 +75,7 @@ void shouldSerializeSimpleModel() throws Exception {
}

@Test
void shouldSerializeStringToStringMapping() throws Exception {
void shouldSerializeStringToStringMapping() {
var schema = SchemaObject.builder()
.type(Set.of(SchemaType.OBJECT.getValue()))
.additionalProperties(ComponentSchema.of(SchemaObject.builder()
Expand All @@ -95,7 +95,7 @@ void shouldSerializeStringToStringMapping() throws Exception {
}

@Test
void shouldSerializeModelMapping() throws Exception {
void shouldSerializeModelMapping() {
var schema = SchemaObject.builder()
.type(Set.of(SchemaType.OBJECT.getValue()))
.additionalProperties(ComponentSchema.of(SchemaReference.toSchema("ComplexModel")))
Expand All @@ -113,7 +113,7 @@ void shouldSerializeModelMapping() throws Exception {
}

@Test
void shouldSerializeModelWithExample() throws Exception {
void shouldSerializeModelWithExample() {
var schema = SchemaObject.builder()
.type(Set.of(SchemaType.OBJECT.getValue()))
.properties(Map.of(
Expand Down Expand Up @@ -157,7 +157,7 @@ void shouldSerializeModelWithExample() throws Exception {
}

@Test
void shouldSerializeModelWithBooleans() throws Exception {
void shouldSerializeModelWithBooleans() {
var schema = SchemaObject.builder()
.type(Set.of(SchemaType.OBJECT.getValue()))
.properties(Map.of(
Expand All @@ -182,7 +182,7 @@ void shouldSerializeModelWithBooleans() throws Exception {
}

@Test
void shouldSerializeModelsWithComposition() throws Exception {
void shouldSerializeModelsWithComposition() {
var schemas = Map.of(
"schemas",
Map.of(
Expand Down Expand Up @@ -262,7 +262,7 @@ void shouldSerializeModelsWithComposition() throws Exception {
}

@Test
void shouldSerializeModelsWithPolimorphismSupport() throws Exception {
void shouldSerializeModelsWithPolimorphismSupport() {
var schemas = Map.of(
"schemas",
Map.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class AmqpOperationBindingProcessor extends AbstractOperationBindingProcessor<AmqpAsyncOperationBinding> {
public AmqpOperationBindingProcessor(StringValueResolver stringValueResolver) {
super(stringValueResolver);
super(stringValueResolver, AmqpAsyncOperationBinding.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
package io.github.springwolf.bindings.generic.annotation;
package io.github.springwolf.bindings.generic.annotations;

import io.github.springwolf.core.asyncapi.annotations.AsyncOperationBinding;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package io.github.springwolf.bindings.generic.scanners.operations;

import io.github.springwolf.asyncapi.v3.bindings.OperationBinding;
import io.github.springwolf.bindings.generic.annotation.AsyncGenericOperationBinding;
import io.github.springwolf.bindings.generic.annotations.AsyncGenericOperationBinding;
import io.github.springwolf.core.asyncapi.scanners.bindings.operations.AbstractOperationBindingProcessor;
import io.github.springwolf.core.asyncapi.scanners.bindings.operations.ProcessedOperationBinding;
import org.springframework.util.StringValueResolver;
Expand All @@ -14,7 +14,7 @@ public class AsyncGenericOperationBindingProcessor
extends AbstractOperationBindingProcessor<AsyncGenericOperationBinding> {

public AsyncGenericOperationBindingProcessor(StringValueResolver stringValueResolver) {
super(stringValueResolver);
super(stringValueResolver, AsyncGenericOperationBinding.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class JmsOperationBindingProcessor extends AbstractOperationBindingProcessor<JmsAsyncOperationBinding> {
public JmsOperationBindingProcessor(StringValueResolver stringValueResolver) {
super(stringValueResolver);
super(stringValueResolver, JmsAsyncOperationBinding.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class KafkaChannelBindingProcessor extends AbstractChannelBindingProcesso
KafkaChannelTopicConfiguration.builder().build();

public KafkaChannelBindingProcessor(StringValueResolver stringValueResolver) {
super(stringValueResolver);
super(stringValueResolver, KafkaAsyncChannelBinding.class);
}

protected ProcessedChannelBinding mapToChannelBinding(KafkaAsyncChannelBinding bindingAnnotation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class KafkaOperationBindingProcessor extends AbstractOperationBindingProcessor<KafkaAsyncOperationBinding> {

public KafkaOperationBindingProcessor(StringValueResolver stringValueResolver) {
super(stringValueResolver);
super(stringValueResolver, KafkaAsyncOperationBinding.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class SnsOperationBindingProcessor extends AbstractOperationBindingProcessor<SnsAsyncOperationBinding> {

public SnsOperationBindingProcessor(StringValueResolver stringValueResolver) {
super(stringValueResolver);
super(stringValueResolver, SnsAsyncOperationBinding.class);
}

@Override
Expand Down
Loading
Loading