-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
293 asyncapi $ref resolution are always a class (#300)
- Loading branch information
1 parent
724e307
commit c549887
Showing
30 changed files
with
616 additions
and
105 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
35 changes: 35 additions & 0 deletions
35
multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/SchemaUtil.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,35 @@ | ||
package com.sngular.api.generator.plugin.common.tools; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.sngular.api.generator.plugin.openapi.utils.MapperUtil; | ||
import com.sngular.api.generator.plugin.openapi.utils.OpenApiUtil; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public class SchemaUtil { | ||
|
||
protected SchemaUtil() { | ||
} | ||
|
||
public static JsonNode solveRef(final String refValue, final Map<String, JsonNode> schemaMap, final Path rootFilePath) { | ||
JsonNode solvedRef; | ||
if (StringUtils.isNotEmpty(refValue)) { | ||
if (refValue.startsWith("#")) { | ||
final String refSchemaName = MapperUtil.getRefSchemaName(refValue); | ||
solvedRef = schemaMap.get(refSchemaName); | ||
} else { | ||
final var refValueArr = refValue.split("#"); | ||
final var filePath = refValueArr[0]; | ||
solvedRef = OpenApiUtil.getPojoFromRef(rootFilePath.toAbsolutePath(), filePath); | ||
final var refName = MapperUtil.getRefSchemaName(refValueArr[1]); | ||
schemaMap.putAll(ApiTool.getComponentSchemas(solvedRef)); | ||
solvedRef = solvedRef.findValue(refName); | ||
} | ||
} else { | ||
solvedRef = null; | ||
} | ||
return solvedRef; | ||
} | ||
} |
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
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.