Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<version.org.codehaus.mojo.exec-maven-plugin>3.6.3</version.org.codehaus.mojo.exec-maven-plugin>
<version.com.github.eirslett.frontend-maven-plugin>1.15.4</version.com.github.eirslett.frontend-maven-plugin>
<version.org.sonatype.central-publishing-maven-plugin>0.10.0</version.org.sonatype.central-publishing-maven-plugin>
<version.apicurio-unified-model-generator-plugin>1.2.14</version.apicurio-unified-model-generator-plugin>
<version.apicurio-unified-model-generator-plugin>1.3.0</version.apicurio-unified-model-generator-plugin>
<version.jsweet-maven-plugin>3.1.1.RedHat</version.jsweet-maven-plugin>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,8 @@ public void visitMultiFormatSchema(AsyncApi30MultiFormatSchema node) {
} else {
AsyncApi30Components components = ensureAsyncApi30Components();
String name = generateNodeName(getNameHintFromRef("ImportedSchema"), getComponentNames(components.getSchemas()));
// AsyncAPI 3.0 schemas are a union type, so we manually add to the map
if (components.getSchemas() == null) {
components.setSchemas(new java.util.LinkedHashMap<>());
}
components.getSchemas().put(name, node);
// AsyncAPI 3.0 schemas are a union type, use addSchema() method
components.addSchema(name, node);
node.attach(components);
setPathToImportedNode(node, componentType, name);
}
Expand Down Expand Up @@ -305,25 +302,20 @@ public void visitSchema(Schema node) {

String name = generateNodeName(nameHint, getComponentNames(components.getSchemas()));

// AsyncAPI 3.0 schemas are a union type, so we manually add to the map
if (components.getSchemas() == null) {
components.setSchemas(new java.util.LinkedHashMap<>());
}

// Check if this is a non-JSON schema that needs wrapping
if (isAvroSchema(node)) {
AsyncApi30MultiFormatSchema multiFormatSchema = wrapInMultiFormatSchema(node, "avro");
components.getSchemas().put(name, multiFormatSchema);
components.addSchema(name, multiFormatSchema);
multiFormatSchema.attach(components);
setPathToImportedNode(multiFormatSchema, componentType, name);
} else if (isProtobufSchema(node)) {
AsyncApi30MultiFormatSchema multiFormatSchema = wrapInMultiFormatSchema(node, "protobuf");
components.getSchemas().put(name, multiFormatSchema);
components.addSchema(name, multiFormatSchema);
multiFormatSchema.attach(components);
setPathToImportedNode(multiFormatSchema, componentType, name);
} else {
// Cast to MultiFormatSchemaSchemaUnion (AsyncApi30Schema implements this)
components.getSchemas().put(name, (MultiFormatSchemaSchemaUnion) node);
components.addSchema(name, (MultiFormatSchemaSchemaUnion) node);
node.attach(components);
setPathToImportedNode(node, componentType, name);
}
Expand Down Expand Up @@ -424,10 +416,7 @@ public void importJson(JsonNode jsonNode, String mediaType) {
AsyncApi30MultiFormatSchema multiFormatSchema = wrapJsonInMultiFormatSchema(jsonNode, mediaType);

// Add to components
if (components.getSchemas() == null) {
components.setSchemas(new java.util.LinkedHashMap<>());
}
components.getSchemas().put(name, multiFormatSchema);
components.addSchema(name, multiFormatSchema);
multiFormatSchema.attach(components);
setPathToImportedNode(multiFormatSchema, componentType, name);
}
Expand All @@ -454,10 +443,7 @@ public void importText(String textContent, String mediaType) {
AsyncApi30MultiFormatSchema multiFormatSchema = wrapTextInMultiFormatSchema(textContent, mediaType);

// Add to components
if (components.getSchemas() == null) {
components.setSchemas(new java.util.LinkedHashMap<>());
}
components.getSchemas().put(name, multiFormatSchema);
components.addSchema(name, multiFormatSchema);
multiFormatSchema.attach(components);
setPathToImportedNode(multiFormatSchema, componentType, name);
}
Expand Down