forked from asyncapi/jasyncapi
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Pakisan/feat/2.6.0_components
feat(AsyncAPI 2.6.0): Components
- Loading branch information
Showing
62 changed files
with
4,138 additions
and
306 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...core/src/main/java/com/asyncapi/v2/_6_0/jackson/MapOfReferencesOrObjectsDeserializer.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,56 @@ | ||
package com.asyncapi.v2._6_0.jackson; | ||
|
||
import com.asyncapi.v2._6_0.model.Reference; | ||
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 com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Deserializes AsyncAPI map of parameters | ||
* @param <ObjectType> object | ||
*/ | ||
public abstract class MapOfReferencesOrObjectsDeserializer<ObjectType> extends JsonDeserializer<Map<String, Object>> { | ||
|
||
private final ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
abstract public Class<ObjectType> objectTypeClass(); | ||
|
||
@Override | ||
public Map<String, Object> deserialize(JsonParser jsonParser, | ||
DeserializationContext deserializationContext | ||
) throws IOException, JsonProcessingException { | ||
ObjectCodec objectCodec = jsonParser.getCodec(); | ||
JsonNode map = objectCodec.readTree(jsonParser); | ||
|
||
Map<String, Object> parameters = new HashMap<>(); | ||
|
||
map.fieldNames().forEachRemaining( | ||
fieldName -> { | ||
try { | ||
parameters.put(fieldName, chooseKnownPojo(map.get(fieldName))); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
); | ||
|
||
return parameters; | ||
} | ||
|
||
private Object chooseKnownPojo(JsonNode parametersValue) throws IOException { | ||
if (parametersValue.get("$ref") != null) { | ||
return objectMapper.readValue(parametersValue.toString(), Reference.class); | ||
} else { | ||
return objectMapper.readValue(parametersValue.toString(), objectTypeClass()); | ||
} | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...va/com/asyncapi/v2/_6_0/jackson/model/component/ComponentsCorrelationIdsDeserializer.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,13 @@ | ||
package com.asyncapi.v2._6_0.jackson.model.component; | ||
|
||
import com.asyncapi.v2._6_0.jackson.MapOfReferencesOrObjectsDeserializer; | ||
import com.asyncapi.v2._6_0.model.channel.message.CorrelationId; | ||
|
||
public class ComponentsCorrelationIdsDeserializer extends MapOfReferencesOrObjectsDeserializer<CorrelationId> { | ||
|
||
@Override | ||
public Class<CorrelationId> objectTypeClass() { | ||
return CorrelationId.class; | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...ava/com/asyncapi/v2/_6_0/jackson/model/component/ComponentsMessageTraitsDeserializer.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,14 @@ | ||
package com.asyncapi.v2._6_0.jackson.model.component; | ||
|
||
import com.asyncapi.v2._6_0.jackson.MapOfReferencesOrObjectsDeserializer; | ||
import com.asyncapi.v2._6_0.model.channel.message.CorrelationId; | ||
import com.asyncapi.v2._6_0.model.channel.message.MessageTrait; | ||
|
||
public class ComponentsMessageTraitsDeserializer extends MapOfReferencesOrObjectsDeserializer<MessageTrait> { | ||
|
||
@Override | ||
public Class<MessageTrait> objectTypeClass() { | ||
return MessageTrait.class; | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...ain/java/com/asyncapi/v2/_6_0/jackson/model/component/ComponentsMessagesDeserializer.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,13 @@ | ||
package com.asyncapi.v2._6_0.jackson.model.component; | ||
|
||
import com.asyncapi.v2._6_0.jackson.MapOfReferencesOrObjectsDeserializer; | ||
import com.asyncapi.v2._6_0.model.channel.message.Message; | ||
|
||
public class ComponentsMessagesDeserializer extends MapOfReferencesOrObjectsDeserializer<Message> { | ||
|
||
@Override | ||
public Class<Message> objectTypeClass() { | ||
return Message.class; | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...a/com/asyncapi/v2/_6_0/jackson/model/component/ComponentsOperationTraitsDeserializer.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,14 @@ | ||
package com.asyncapi.v2._6_0.jackson.model.component; | ||
|
||
import com.asyncapi.v2._6_0.jackson.MapOfReferencesOrObjectsDeserializer; | ||
import com.asyncapi.v2._6_0.model.channel.message.CorrelationId; | ||
import com.asyncapi.v2._6_0.model.channel.operation.OperationTrait; | ||
|
||
public class ComponentsOperationTraitsDeserializer extends MapOfReferencesOrObjectsDeserializer<OperationTrait> { | ||
|
||
@Override | ||
public Class<OperationTrait> objectTypeClass() { | ||
return OperationTrait.class; | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...n/java/com/asyncapi/v2/_6_0/jackson/model/component/ComponentsParametersDeserializer.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,13 @@ | ||
package com.asyncapi.v2._6_0.jackson.model.component; | ||
|
||
import com.asyncapi.v2._6_0.jackson.MapOfReferencesOrObjectsDeserializer; | ||
import com.asyncapi.v2._6_0.model.channel.Parameter; | ||
|
||
public class ComponentsParametersDeserializer extends MapOfReferencesOrObjectsDeserializer<Parameter> { | ||
|
||
@Override | ||
public Class<Parameter> objectTypeClass() { | ||
return Parameter.class; | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...main/java/com/asyncapi/v2/_6_0/jackson/model/component/ComponentsSchemasDeserializer.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,13 @@ | ||
package com.asyncapi.v2._6_0.jackson.model.component; | ||
|
||
import com.asyncapi.v2._6_0.jackson.MapOfReferencesOrObjectsDeserializer; | ||
import com.asyncapi.v2._6_0.model.schema.Schema; | ||
|
||
public class ComponentsSchemasDeserializer extends MapOfReferencesOrObjectsDeserializer<Schema> { | ||
|
||
@Override | ||
public Class<Schema> objectTypeClass() { | ||
return Schema.class; | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...a/com/asyncapi/v2/_6_0/jackson/model/component/ComponentsSecuritySchemesDeserializer.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,13 @@ | ||
package com.asyncapi.v2._6_0.jackson.model.component; | ||
|
||
import com.asyncapi.v2._6_0.jackson.MapOfReferencesOrObjectsDeserializer; | ||
import com.asyncapi.v2._6_0.model.security_scheme.SecurityScheme; | ||
|
||
public class ComponentsSecuritySchemesDeserializer extends MapOfReferencesOrObjectsDeserializer<SecurityScheme> { | ||
|
||
@Override | ||
public Class<SecurityScheme> objectTypeClass() { | ||
return SecurityScheme.class; | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...a/com/asyncapi/v2/_6_0/jackson/model/component/ComponentsServerVariablesDeserializer.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,13 @@ | ||
package com.asyncapi.v2._6_0.jackson.model.component; | ||
|
||
import com.asyncapi.v2._6_0.jackson.MapOfReferencesOrObjectsDeserializer; | ||
import com.asyncapi.v2._6_0.model.server.ServerVariable; | ||
|
||
public class ComponentsServerVariablesDeserializer extends MapOfReferencesOrObjectsDeserializer<ServerVariable> { | ||
|
||
@Override | ||
public Class<ServerVariable> objectTypeClass() { | ||
return ServerVariable.class; | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...main/java/com/asyncapi/v2/_6_0/jackson/model/component/ComponentsServersDeserializer.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,13 @@ | ||
package com.asyncapi.v2._6_0.jackson.model.component; | ||
|
||
import com.asyncapi.v2._6_0.jackson.MapOfReferencesOrObjectsDeserializer; | ||
import com.asyncapi.v2._6_0.model.server.Server; | ||
|
||
public class ComponentsServersDeserializer extends MapOfReferencesOrObjectsDeserializer<Server> { | ||
|
||
@Override | ||
public Class<Server> objectTypeClass() { | ||
return Server.class; | ||
} | ||
|
||
} |
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
Oops, something went wrong.