Skip to content

Commit

Permalink
Merge pull request #195 from asyncapi/release/1.0.0-RC
Browse files Browse the repository at this point in the history
build: 1.0.0-RC
  • Loading branch information
Pakisan authored Apr 20, 2024
2 parents 92c3acd + f662aa2 commit 0c168d4
Show file tree
Hide file tree
Showing 1,093 changed files with 54,099 additions and 2,466 deletions.
1 change: 1 addition & 0 deletions .idea/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0-RC] - 2024-04-20

### Added

- OpenAPI Schema: 3.0.0, 3.0.1, 3.0.2, 3.0.3
- Avro Schema: 1.9.0, 1.9.1, 1.9.2, 1.10.0, 1.10.1, 1.10.2, 1.11.0, 1.11.1
- JsonSchema: Draft-07

### Changed

- MultiFormatSchema can hold AsyncAPI, OpenAPI, Avro and Json Schemas
- Schema was divided to AsyncAPISchema and JsonSchema

## [1.0.0-EAP-3] - 2024-03-10

Kudos to:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
> ⚠️ This project doesn't support AsyncAPI 1.x
---

[![Version](https://img.shields.io/maven-central/v/com.asyncapi/asyncapi-core?logo=apache-maven)](https://central.sonatype.com/artifact/com.asyncapi/asyncapi-core/1.0.0-EAP-3)
[![Version](https://img.shields.io/maven-central/v/com.asyncapi/asyncapi-core?logo=apache-maven)](https://central.sonatype.com/artifact/com.asyncapi/asyncapi-core/1.0.0-RC)

## Overview
JVM-friendly bindings for AsyncAPI. It allows you to read or write specifications for your asynchronous API through code
Expand Down
2 changes: 1 addition & 1 deletion asyncapi-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>asyncapi</artifactId>
<groupId>com.asyncapi</groupId>
<version>1.0.0-EAP-3</version>
<version>1.0.0-RC</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.asyncapi.v3._0_0.jackson.model.channel.message;

import com.asyncapi.v3.Reference;
import com.asyncapi.v3.schema.Schema;
import com.asyncapi.v3.schema.MultiFormatSchema;
import com.asyncapi.v3.schema.AsyncAPISchema;
import com.asyncapi.v3.schema.multiformat.MultiFormatSchema;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
Expand Down Expand Up @@ -56,14 +56,14 @@ private Object chooseKnownPojo(JsonNode jsonNode, ObjectCodec objectCodec) throw
if (ref != null) {
return jsonParser.readValueAs(Reference.class);
} else {
return jsonParser.readValueAs(Schema.class);
return jsonParser.readValueAs(AsyncAPISchema.class);
}
}
}

private Object readAsObject(JsonNode jsonNode, ObjectCodec objectCodec) throws IOException {
try (JsonParser jsonParser = jsonNode.traverse(objectCodec)) {
return jsonParser.readValueAs(Schema.class);
return jsonParser.readValueAs(AsyncAPISchema.class);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.asyncapi.v3._0_0.jackson.model.channel.message;

import com.asyncapi.v3.Reference;
import com.asyncapi.v3.schema.MultiFormatSchema;
import com.asyncapi.v3.schema.Schema;
import com.asyncapi.v3.schema.multiformat.MultiFormatSchema;
import com.asyncapi.v3.schema.AsyncAPISchema;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
Expand Down Expand Up @@ -56,14 +56,14 @@ private Object chooseKnownPojo(JsonNode jsonNode, ObjectCodec objectCodec) throw
if (ref != null) {
return jsonParser.readValueAs(Reference.class);
} else {
return jsonParser.readValueAs(Schema.class);
return jsonParser.readValueAs(AsyncAPISchema.class);
}
}
}

private Object readAsObject(JsonNode jsonNode, ObjectCodec objectCodec) throws IOException {
try (JsonParser jsonParser = jsonNode.traverse(objectCodec)) {
return jsonParser.readValueAs(Schema.class);
return jsonParser.readValueAs(AsyncAPISchema.class);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.asyncapi.v3._0_0.jackson.model.component;

import com.asyncapi.v3.Reference;
import com.asyncapi.v3.schema.MultiFormatSchema;
import com.asyncapi.v3.schema.Schema;
import com.asyncapi.v3.schema.multiformat.MultiFormatSchema;
import com.asyncapi.v3.schema.AsyncAPISchema;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
Expand All @@ -17,8 +17,8 @@

public class ComponentsSchemasDeserializer extends JsonDeserializer<Object> {

public Class<Schema> objectTypeClass() {
return Schema.class;
public Class<AsyncAPISchema> objectTypeClass() {
return AsyncAPISchema.class;
}

public Class<?> referenceClass() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.asyncapi.v3._0_0.model.ExternalDocumentation;
import com.asyncapi.v3._0_0.model.Tag;
import com.asyncapi.v3.jackson.binding.message.MessageBindingsDeserializer;
import com.asyncapi.v3.schema.multiformat.MultiFormatSchema;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.*;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -39,14 +40,14 @@ public class Message extends ExtendableObject {
* <p>
* It MUST NOT define the protocol headers.
* <p>
* If this is a {@link com.asyncapi.v3.schema.Schema}, then the schemaFormat will be assumed to
* If this is a {@link com.asyncapi.v3.schema.AsyncAPISchema}, then the schemaFormat will be assumed to
* be "application/vnd.aai.asyncapi+json;version=asyncapi" where the version
* is equal to the AsyncAPI Version String.
* <p>
* MUST BE:
* <ul>
* <li>{@link com.asyncapi.v3.schema.Schema}</li>
* <li>{@link com.asyncapi.v3.schema.MultiFormatSchema}</li>
* <li>{@link com.asyncapi.v3.schema.AsyncAPISchema}</li>
* <li>{@link MultiFormatSchema}</li>
* <li>{@link com.asyncapi.v3.Reference}</li>
* </ul>
*/
Expand All @@ -57,13 +58,13 @@ public class Message extends ExtendableObject {
/**
* Definition of the message payload.
* <p>
* If this is a {@link com.asyncapi.v3.schema.Schema}, then the schemaFormat will be assumed to be
* If this is a {@link com.asyncapi.v3.schema.AsyncAPISchema}, then the schemaFormat will be assumed to be
* "application/vnd.aai.asyncapi+json;version=asyncapi" where the version is equal to the AsyncAPI Version String.
* <p>
* MUST BE:
* <ul>
* <li>{@link com.asyncapi.v3.schema.Schema}</li>
* <li>{@link com.asyncapi.v3.schema.MultiFormatSchema}</li>
* <li>{@link com.asyncapi.v3.schema.AsyncAPISchema}</li>
* <li>{@link MultiFormatSchema}</li>
* <li>{@link com.asyncapi.v3.Reference}</li>
* </ul>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.asyncapi.v3._0_0.model.ExternalDocumentation;
import com.asyncapi.v3._0_0.model.Tag;
import com.asyncapi.v3.jackson.binding.message.MessageBindingsDeserializer;
import com.asyncapi.v3.schema.multiformat.MultiFormatSchema;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.*;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -39,14 +40,14 @@ public class MessageTrait extends ExtendableObject {
* <p>
* It MUST NOT define the protocol headers.
* <p>
* If this is a {@link com.asyncapi.v3.schema.Schema}, then the schemaFormat will be assumed to
* If this is a {@link com.asyncapi.v3.schema.AsyncAPISchema}, then the schemaFormat will be assumed to
* be "application/vnd.aai.asyncapi+json;version=asyncapi" where the version
* is equal to the AsyncAPI Version String.
* <p>
* MUST BE:
* <ul>
* <li>{@link com.asyncapi.v3.schema.Schema}</li>
* <li>{@link com.asyncapi.v3.schema.MultiFormatSchema}</li>
* <li>{@link com.asyncapi.v3.schema.AsyncAPISchema}</li>
* <li>{@link MultiFormatSchema}</li>
* <li>{@link com.asyncapi.v3.Reference}</li>
* </ul>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import com.asyncapi.v3.jackson.binding.message.MessageBindingsDeserializer;
import com.asyncapi.v3.jackson.binding.operation.OperationBindingsDeserializer;
import com.asyncapi.v3.jackson.binding.server.ServerBindingsDeserializer;
import com.asyncapi.v3.schema.MultiFormatSchema;
import com.asyncapi.v3.schema.Schema;
import com.asyncapi.v3.schema.multiformat.MultiFormatSchema;
import com.asyncapi.v3.schema.AsyncAPISchema;
import com.asyncapi.v3.security_scheme.SecurityScheme;
import com.asyncapi.v3.ExtendableObject;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
Expand Down Expand Up @@ -52,12 +52,12 @@ public class Components extends ExtendableObject {
/**
* An object to hold reusable Schema Object.
* <p>
* If this is a {@link Schema}, then the schemaFormat will be assumed to be "application/vnd.aai.asyncapi+json;version=asyncapi"
* If this is a {@link AsyncAPISchema}, then the schemaFormat will be assumed to be "application/vnd.aai.asyncapi+json;version=asyncapi"
* where the version is equal to the AsyncAPI Version String.
* <p>
* MUST BE:
* <ul>
* <li>{@link Schema}</li>
* <li>{@link AsyncAPISchema}</li>
* <li>{@link MultiFormatSchema}</li>
* <li>{@link Reference}</li>
* </ul>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.asyncapi.v3.binding.channel.ws;

import com.asyncapi.v3.schema.Schema;
import com.asyncapi.v3.schema.AsyncAPISchema;
import com.asyncapi.v3.binding.channel.ChannelBinding;
import com.fasterxml.jackson.annotation.JsonClassDescription;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down Expand Up @@ -43,7 +43,7 @@ public class WebSocketsChannelBinding extends ChannelBinding {
@Nullable
@JsonProperty("query")
@JsonPropertyDescription("A Schema object containing the definitions for each query parameter. This schema MUST be of type object and have a properties key.")
private Schema query;
private AsyncAPISchema query;

/**
* A Schema object containing the definitions of the HTTP headers to use when establishing the connection.
Expand All @@ -52,7 +52,7 @@ public class WebSocketsChannelBinding extends ChannelBinding {
@Nullable
@JsonProperty("headers")
@JsonPropertyDescription("A Schema object containing the definitions of the HTTP headers to use when establishing the connection. This schema MUST be of type object and have a properties key.")
private Schema headers;
private AsyncAPISchema headers;

/**
* The version of this binding. If omitted, "latest" MUST be assumed.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.asyncapi.v3.binding.message.anypointmq;

import com.asyncapi.v3.schema.Schema;
import com.asyncapi.v3.schema.AsyncAPISchema;
import com.asyncapi.v3.binding.message.MessageBinding;
import com.fasterxml.jackson.annotation.JsonClassDescription;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down Expand Up @@ -31,7 +31,7 @@ public class AnypointMQMessageBinding extends MessageBinding {
@Nullable
@JsonProperty("headers")
@JsonPropertyDescription("A Schema object containing the definitions for Anypoint MQ-specific headers (so-called protocol headers). This schema MUST be of type object and have a properties key. Examples of Anypoint MQ protocol headers are messageId and messageGroupId.")
private Schema headers;
private AsyncAPISchema headers;

/**
* The version of this binding.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.asyncapi.v3.binding.message.http;

import com.asyncapi.v3.schema.Schema;
import com.asyncapi.v3.schema.AsyncAPISchema;
import com.asyncapi.v3.binding.message.MessageBinding;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
Expand Down Expand Up @@ -30,7 +30,7 @@ public class HTTPMessageBinding extends MessageBinding {
@Nullable
@JsonProperty("headers")
@JsonPropertyDescription("A Schema object containing the definitions for each query parameter. This schema MUST be of type object and have a properties key.")
private Schema headers;
private AsyncAPISchema headers;

/**
* The version of this binding.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.asyncapi.v3.binding.message.kafka;

import com.asyncapi.v3.schema.Schema;
import com.asyncapi.v3.schema.AsyncAPISchema;
import com.asyncapi.v3.binding.message.MessageBinding;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
Expand Down Expand Up @@ -29,7 +29,7 @@ public class KafkaMessageBinding extends MessageBinding {
@Nullable
@JsonProperty("key")
@JsonPropertyDescription("The message key.")
private Schema key;
private AsyncAPISchema key;

/**
* If a Schema Registry is used when performing this operation, tells where the id of schema is stored (e.g. header or payload).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.asyncapi.v3.binding.operation.http;

import com.asyncapi.v3.schema.Schema;
import com.asyncapi.v3.schema.AsyncAPISchema;
import com.asyncapi.v3.binding.operation.OperationBinding;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
Expand Down Expand Up @@ -52,7 +52,7 @@ public class HTTPOperationBinding extends OperationBinding {
@Nullable
@JsonProperty("query")
@JsonPropertyDescription("A Schema object containing the definitions for each query parameter. This schema MUST be of type object and have a properties key.")
private Schema query;
private AsyncAPISchema query;

/**
* The version of this binding. If omitted, "latest" MUST be assumed.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.asyncapi.v3.binding.operation.kafka;

import com.asyncapi.v3.schema.Schema;
import com.asyncapi.v3.schema.AsyncAPISchema;
import com.asyncapi.v3.binding.operation.OperationBinding;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
Expand Down Expand Up @@ -29,15 +29,15 @@ public class KafkaOperationBinding extends OperationBinding {
@Nullable
@JsonProperty("groupId")
@JsonPropertyDescription("Id of the consumer group.")
private Schema groupId;
private AsyncAPISchema groupId;

/**
* Id of the consumer inside a consumer group.
*/
@Nullable
@JsonProperty("clientId")
@JsonPropertyDescription("Id of the consumer inside a consumer group.")
private Schema clientId;
private AsyncAPISchema clientId;

/**
* The version of this binding. If omitted, "latest" MUST be assumed.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.asyncapi.v3.jackson;

import com.asyncapi.v3.schema.Schema;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
Expand All @@ -13,7 +12,9 @@
import java.util.ArrayList;
import java.util.List;

public class SchemaItemsDeserializer extends JsonDeserializer<Object> {
public abstract class SchemaItemsDeserializer<Schema> extends JsonDeserializer<Object> {

abstract public Class<Schema> schemaClass();

@Override
public Object deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
Expand All @@ -39,7 +40,7 @@ private List<Schema> readAsListOfSchemas(ArrayNode arrayNode, ObjectCodec object

private Schema readAsSchema(JsonNode jsonNode, ObjectCodec objectCodec) throws IOException {
try (JsonParser parser = jsonNode.traverse(objectCodec)) {
return parser.readValueAs(Schema.class);
return parser.readValueAs(schemaClass());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.asyncapi.v3.jackson.schema;

import com.asyncapi.v3.schema.AsyncAPISchema;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;

import java.io.IOException;

/**
* @author Guillaume LAMIRAND (guillaume.lamirand at graviteesource.com)
* @author GraviteeSource Team
*/
public class AsyncAPISchemaAdditionalPropertiesDeserializer extends JsonDeserializer<Object> {

@Override
public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
ObjectCodec objectCodec = p.getCodec();
JsonNode node = objectCodec.readTree(p);

return chooseKnownPojo(node, objectCodec);
}

private Object chooseKnownPojo(JsonNode jsonNode, final ObjectCodec objectCodec) throws IOException {
try (JsonParser jsonParser = jsonNode.traverse(objectCodec)) {
if (jsonNode.isBoolean()) {
return jsonNode.asBoolean();
} else {
return jsonParser.readValueAs(AsyncAPISchema.class);
}
}
}
}
Loading

0 comments on commit 0c168d4

Please sign in to comment.