-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,822 additions
and
2 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...com/asyncapi/v3/jackson/schema/openapi/OpenAPISchemaAdditionalPropertiesDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.asyncapi.v3.jackson.schema.openapi; | ||
|
||
import com.asyncapi.v3.schema.openapi.OpenAPISchema; | ||
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 Pavel Bodiachevskii | ||
* @version 3.0.0 | ||
*/ | ||
public class OpenAPISchemaAdditionalPropertiesDeserializer 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(OpenAPISchema.class); | ||
} | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...c/main/java/com/asyncapi/v3/jackson/schema/openapi/OpenAPISchemaAnyValueDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.asyncapi.v3.jackson.schema.openapi; | ||
|
||
import com.asyncapi.v3.jackson.schema.SchemaAnyValueDeserializer; | ||
import com.asyncapi.v3.schema.openapi.OpenAPISchema; | ||
|
||
/** | ||
* @author Pavel Bodiachevskii | ||
*/ | ||
public class OpenAPISchemaAnyValueDeserializer extends SchemaAnyValueDeserializer<OpenAPISchema> { | ||
|
||
@Override | ||
public Class<OpenAPISchema> schemaClass() { | ||
return OpenAPISchema.class; | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
asyncapi-core/src/main/java/com/asyncapi/v3/schema/openapi/Discriminator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.asyncapi.v3.schema.openapi; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyDescription; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* When request bodies or response payloads may be one of a number of different schemas, | ||
* a discriminator object can be used to aid in serialization, deserialization, and validation. | ||
* <p> | ||
* The discriminator is a specific object in a schema which is used to inform the consumer of the | ||
* specification of an alternative schema based on the value associated with it. | ||
* <p> | ||
* When using the discriminator, inline schemas will not be considered. | ||
* <p> | ||
* The discriminator attribute is legal only when using one of the composite keywords oneOf, anyOf, allOf. | ||
* | ||
* @see <a href="https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#discriminator-object">Discriminator Object</a> | ||
* @see <a href="https://github.com/swagger-api/swagger-core/blob/v2.1.13/modules/swagger-models/src/main/java/io/swagger/v3/oas/models/media/Discriminator.java">Discriminator</a> | ||
* | ||
* @author Pavel Bodiachevskii | ||
* @version 3.0.0 | ||
*/ | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Discriminator { | ||
|
||
/** | ||
* <b>REQUIRED</b>. | ||
* <p> | ||
* The name of the property in the payload that will hold the discriminator value. | ||
*/ | ||
@NotNull | ||
@JsonProperty("propertyName") | ||
@JsonPropertyDescription("The name of the property in the payload that will hold the discriminator value.") | ||
public String propertyName; | ||
|
||
/** | ||
* An object to hold mappings between payload values and schema names or references. | ||
*/ | ||
@Nullable | ||
@JsonProperty("mapping") | ||
@JsonPropertyDescription("An object to hold mappings between payload values and schema names or references.") | ||
public Map<String, String> mapping; | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
asyncapi-core/src/main/java/com/asyncapi/v3/schema/openapi/ExternalDocumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.asyncapi.v3.schema.openapi; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyDescription; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Allows referencing an external resource for extended documentation. | ||
* | ||
* @see <a href="https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#external-documentation-object">Schema Object</a> | ||
* @see <a href="https://github.com/swagger-api/swagger-core/blob/v2.1.13/modules/swagger-models/src/main/java/io/swagger/v3/oas/models/ExternalDocumentation.java">ExternalDocumentation</a> | ||
* | ||
* @author Pavel Bodiachevskii | ||
* @version 3.0.0 | ||
*/ | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ExternalDocumentation { | ||
|
||
/** | ||
* A short description of the target documentation. | ||
* <p> | ||
* <a href="http://spec.commonmark.org/">CommonMark syntax</a> <b>MAY</b> be used for rich text representation. | ||
*/ | ||
@Nullable | ||
@JsonProperty("description") | ||
@JsonPropertyDescription("A short description of the target documentation.") | ||
public String description; | ||
|
||
/** | ||
* <b>REQUIRED</b>. | ||
* <p> | ||
* The URL for the target documentation. Value <b>MUST</b> be in the format of a URL. | ||
*/ | ||
@NotNull | ||
@JsonProperty("url") | ||
@JsonPropertyDescription("The URL for the target documentation.") | ||
public String url; | ||
|
||
} |
Oops, something went wrong.