diff --git a/multiapi-engine/pom.xml b/multiapi-engine/pom.xml
index 9e2e85ea..f2ee1008 100644
--- a/multiapi-engine/pom.xml
+++ b/multiapi-engine/pom.xml
@@ -4,7 +4,7 @@
com.sngular
multiapi-engine
- 6.0.2
+ 6.0.3
jar
diff --git a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/asyncapi/AsyncApiGenerator.java b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/asyncapi/AsyncApiGenerator.java
index 2a57a28c..fe73789c 100644
--- a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/asyncapi/AsyncApiGenerator.java
+++ b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/asyncapi/AsyncApiGenerator.java
@@ -504,7 +504,8 @@ private String processMessageRef(final JsonNode messageBody, final String modelP
final String messageContent = ApiTool.getRefValue(messageBody);
if (messageContent.startsWith("#")) {
namespace = processModelPackage(MapperUtil.getLongRefClass(messageBody), modelPackage);
- } else if (messageContent.contains("#")) {
+ } else if (messageContent.contains("#") || StringUtils.endsWith(messageContent, "yml")
+ || StringUtils.endsWith(messageContent, "yaml") || StringUtils.endsWith(messageContent, "json")) {
namespace = processExternalRef(modelPackage, ymlParent, messageBody);
} else {
namespace = processExternalAvro(ymlParent, messageContent);
@@ -538,16 +539,20 @@ private String processExternalAvro(final FileLocation ymlParent, final String me
private String processExternalRef(final String modelPackage, final FileLocation ymlParent, final JsonNode message) throws IOException {
final String[] pathToFile = message.get(REF).asText().split("#");
final String filePath = pathToFile[0];
- final String componentPath = pathToFile[1];
- final String component;
- final String[] path = MapperUtil.splitName(componentPath);
- component = path[path.length - 2] + SLASH + path[path.length - 1];
-
final JsonNode node = ApiTool.nodeFromFile(ymlParent, filePath, FactoryTypeEnum.YML);
- if (Objects.nonNull(node.findValue(path[path.length - 2]).get(path[path.length - 1]))) {
- return processModelPackage(component, modelPackage);
+ if (pathToFile.length > 1) {
+ final String componentPath = pathToFile[1];
+ final String component;
+ final String[] path = MapperUtil.splitName(componentPath);
+ component = path[path.length - 2] + SLASH + path[path.length - 1];
+
+ if (Objects.nonNull(node.findValue(path[path.length - 2]).get(path[path.length - 1]))) {
+ return processModelPackage(component, modelPackage);
+ } else {
+ throw new ExternalRefComponentNotFoundException(component, filePath);
+ }
} else {
- throw new ExternalRefComponentNotFoundException(component, filePath);
+ return processModelPackage(MapperUtil.getNameFromFile(filePath), modelPackage);
}
}
@@ -570,18 +575,7 @@ private void processKafkaBindings(final ProcessBindingsResultBuilder bindingsRes
}
}
- private String capitalizeWithPrefix(final String name) {
- final StringBuilder response = new StringBuilder();
- if (name.contains(SLASH)) {
- final var splitPackage = MapperUtil.splitName(name);
- for (int i = 0; i < splitPackage.length; i++) {
- response.append(PACKAGE_SEPARATOR_STR).append(i < splitPackage.length - 1 ? splitPackage[i] : StringUtils.capitalize(splitPackage[i]));
- }
- } else {
- response.append(PACKAGE_SEPARATOR_STR).append(StringUtils.capitalize(name));
- }
- return response.toString();
- }
+
private String processModelPackage(final String extractedPackage, final String modelPackage) {
final String processedPackage;
@@ -591,7 +585,7 @@ private String processModelPackage(final String extractedPackage, final String m
final var className = splitPackage[splitPackage.length - 1];
processedPackage = modelPackage + PACKAGE_SEPARATOR_STR + StringUtils.capitalize(className);
} else {
- processedPackage = modelPackage + capitalizeWithPrefix(extractedPackage);
+ processedPackage = modelPackage + MapperUtil.capitalizeWithPrefix(extractedPackage);
}
} else if (extractedPackage.contains(PACKAGE_SEPARATOR_STR)) {
final var splitPackage = MapperUtil.splitName(extractedPackage);
@@ -599,7 +593,7 @@ private String processModelPackage(final String extractedPackage, final String m
processedPackage =
StringUtils.join(PACKAGE_SEPARATOR_STR, Arrays.spliterator(splitPackage, 0, splitPackage.length)) + PACKAGE_SEPARATOR_STR + StringUtils.capitalize(className);
} else {
- processedPackage = DEFAULT_ASYNCAPI_MODEL_PACKAGE + capitalizeWithPrefix(extractedPackage);
+ processedPackage = DEFAULT_ASYNCAPI_MODEL_PACKAGE + MapperUtil.capitalizeWithPrefix(extractedPackage);
}
return processedPackage;
diff --git a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/asyncapi/util/ReferenceProcessor.java b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/asyncapi/util/ReferenceProcessor.java
index 8e22b9a7..d8856ba3 100644
--- a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/asyncapi/util/ReferenceProcessor.java
+++ b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/asyncapi/util/ReferenceProcessor.java
@@ -12,6 +12,7 @@
import com.sngular.api.generator.plugin.common.tools.ApiTool;
import com.sngular.api.generator.plugin.common.tools.MapperUtil;
import lombok.Builder;
+import org.apache.commons.lang3.StringUtils;
public final class ReferenceProcessor {
@@ -78,11 +79,15 @@ private JsonNode solveRef(final FileLocation ymlParent, final String[] path, fin
if (filePath.endsWith(YML) || filePath.endsWith(JSON) || filePath.endsWith(YAML)) {
final JsonNode node = ApiTool.nodeFromFile(ymlParent, filePath, FactoryTypeEnum.YML);
- if (node.findValue(path[path.length - 2]).has(path[path.length - 1])) {
- returnNode = node.findValue(path[path.length - 2]).get(path[path.length - 1]);
- checkReference(node, returnNode);
+ if (StringUtils.contains(reference, "#")) {
+ if (node.findValue(path[path.length - 2]).has(path[path.length - 1])) {
+ returnNode = node.findValue(path[path.length - 2]).get(path[path.length - 1]);
+ checkReference(node, returnNode);
+ } else {
+ throw new NonSupportedSchemaException(node.toPrettyString());
+ }
} else {
- throw new NonSupportedSchemaException(node.toPrettyString());
+ returnNode = node;
}
} else if (filePath.endsWith(AVSC)) {
returnNode = ApiTool.nodeFromFile(ymlParent, filePath, FactoryTypeEnum.AVRO);
diff --git a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/MapperUtil.java b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/MapperUtil.java
index 5c7877d8..cc101768 100644
--- a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/MapperUtil.java
+++ b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/MapperUtil.java
@@ -17,10 +17,12 @@ public class MapperUtil {
private static final String REF = "$ref";
- private static final String DIVISOR = "([./])";
+ private static final String[] DIVISOR = {"/", "-", "_"};
private static final String SLASH = "/";
+ private static final String PACKAGE_SEPARATOR_STR = ".";
+
private MapperUtil() {}
public static String getSimpleType(final JsonNode schema, final CommonSpecFile specFile) {
@@ -29,7 +31,7 @@ public static String getSimpleType(final JsonNode schema, final CommonSpecFile s
if (checkIfNumber(nodeType)) {
type = processNumber(schema);
} else if (ApiTool.hasRef(schema)) {
- type = getPojoName(getRefSchemaName(schema), specFile);
+ type = getPojoName(getRefSchemaName(schema, null), specFile);
} else if (TypeConstants.ARRAY.equalsIgnoreCase(nodeType)) {
type = TypeConstants.ARRAY;
} else {
@@ -39,16 +41,24 @@ public static String getSimpleType(final JsonNode schema, final CommonSpecFile s
}
public static String[] splitName(final String name) {
- return ArrayUtils.removeAllOccurrences(name.split(DIVISOR), "");
+ return ArrayUtils.removeAllOccurrences(name.split("\\W+"), "");
}
public static String packageToFolder(final String packageName) {
return StringUtils.replace(packageName, ".", SLASH);
}
- public static String getRefSchemaName(final JsonNode parameter) {
+ public static String getRefSchemaName(final JsonNode parameter, String defaultSchemaName) {
final String[] pathObjectRef = ApiTool.getRefValue(parameter).split("/");
- return pathObjectRef[pathObjectRef.length - 1];
+ final String schemaName;
+ if (pathObjectRef[pathObjectRef.length - 1].contains(".yml")
+ || pathObjectRef[pathObjectRef.length - 1].contains(".yaml")
+ || pathObjectRef[pathObjectRef.length - 1].contains(".json")) {
+ schemaName = StringUtils.defaultIfEmpty(defaultSchemaName, "");
+ } else {
+ schemaName = pathObjectRef[pathObjectRef.length - 1];
+ }
+ return schemaName;
}
public static String getRefSchemaKey(final JsonNode parameter) {
@@ -109,7 +119,7 @@ public static String getTypeArray(final JsonNode array, final CommonSpecFile spe
} else if (ApiTool.isNumber(ApiTool.getItems(array))) {
typeArray = ApiTool.getNumberType(ApiTool.getItems(array));
} else if (ApiTool.hasRef(ApiTool.getItems(array))) {
- typeArray = getPojoName(MapperUtil.getRefSchemaName(ApiTool.getItems(array)), specFile);
+ typeArray = getPojoName(MapperUtil.getRefSchemaName(ApiTool.getItems(array), null), specFile);
}
return typeArray;
}
@@ -120,10 +130,17 @@ public static String getPojoName(final String namePojo, final CommonSpecFile spe
+ (StringUtils.isNotBlank(specFile.getModelNameSuffix()) ? specFile.getModelNameSuffix() : "");
}
- public static String getRef(final JsonNode schema, final CommonSpecFile specFile) {
- final String typeObject;
- typeObject = getPojoName(getRefSchemaName(schema), specFile);
- return typeObject;
+ public static String calculatePrefixName(final String namePojo, final CommonSpecFile specFile) {
+ return (StringUtils.isNotBlank(specFile.getModelNamePrefix()) ? specFile.getModelNamePrefix() : "")
+ + StringUtils.capitalize(namePojo);
+ }
+
+ public static String getPojoNameFromRef(final JsonNode schema, final CommonSpecFile specFile, String defaultPojoName) {
+ String pojoName = getRefSchemaName(schema, defaultPojoName);
+ if (!StringUtils.equalsIgnoreCase(pojoName, defaultPojoName)) {
+ pojoName = getPojoName(pojoName, specFile);
+ }
+ return pojoName;
}
public static String getDateType(final JsonNode schema, final CommonSpecFile specFile) {
@@ -173,4 +190,37 @@ public static String getLongRefClass(final JsonNode schema) {
final String[] pathObjectRef = getStrings(schema);
return pathObjectRef[pathObjectRef.length - 2] + "/" + pathObjectRef[pathObjectRef.length - 1];
}
+
+ public static String getNameFromFile(final String filePath) {
+ return capitalizeFileName(StringUtils
+ .removeStart(filePath, "./")
+ .substring(0, filePath.lastIndexOf('.') - 2)
+ .replace("\\/", "."));
+ }
+
+ public static String capitalizeWithPrefix(final String name) {
+ final StringBuilder response = new StringBuilder();
+ if (StringUtils.containsAny(name, DIVISOR)) {
+ final var splitPackage = MapperUtil.splitName(name);
+ for (int i = 0; i < splitPackage.length; i++) {
+ response.append(PACKAGE_SEPARATOR_STR).append(i < splitPackage.length - 1 ? splitPackage[i] : StringUtils.capitalize(splitPackage[i]));
+ }
+ } else {
+ response.append(PACKAGE_SEPARATOR_STR).append(StringUtils.capitalize(name));
+ }
+ return response.toString();
+ }
+
+ public static String capitalizeFileName(final String name) {
+ final StringBuilder response = new StringBuilder();
+ if (StringUtils.containsAny(name, DIVISOR)) {
+ final var splitPackage = MapperUtil.splitName(name);
+ for (String s : splitPackage) {
+ response.append(StringUtils.capitalize(s));
+ }
+ } else {
+ response.append(StringUtils.capitalize(name));
+ }
+ return response.toString();
+ }
}
diff --git a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/ModelBuilder.java b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/ModelBuilder.java
index e4369cdb..d479e2fb 100644
--- a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/ModelBuilder.java
+++ b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/ModelBuilder.java
@@ -38,8 +38,13 @@ public static SchemaObject buildSchemaObject(
antiLoopList.add(WordUtils.capitalizeFully(className));
final var schemaBuilder = SchemaObject.builder()
- .schemaName(WordUtils.capitalizeFully(className))
- .className(MapperUtil.getPojoName(className, specFile));
+ .schemaName(WordUtils.capitalizeFully(className));
+ final var calculatedInlinePrefix = MapperUtil.calculatePrefixName("Inline", specFile);
+ if (!StringUtils.startsWith(className, calculatedInlinePrefix)) {
+ schemaBuilder.className(MapperUtil.getPojoName(className, specFile));
+ } else {
+ schemaBuilder.className(className);
+ }
if (!ApiTool.isEnum(model)) {
final var listSchema = getFields(null, totalSchemas, model, specFile, compositedSchemas, antiLoopList, WordUtils.capitalizeFully(className), baseDir);
@@ -148,7 +153,7 @@ private static Set getFields(final String buildingSchema,
baseDir));
}
} else if (TypeConstants.ARRAY.equalsIgnoreCase(ApiTool.getType(schema))) {
- final String itemType = ApiTool.hasRef(ApiTool.getItems(schema)) ? MapperUtil.getRef(ApiTool.getItems(schema), specFile) : ApiTool.getType(ApiTool.getItems(schema));
+ final String itemType = ApiTool.hasRef(ApiTool.getItems(schema)) ? MapperUtil.getPojoNameFromRef(ApiTool.getItems(schema), specFile, null) : ApiTool.getType(ApiTool.getItems(schema));
fieldObjectArrayList.add(SchemaFieldObject.builder()
.baseName("items")
.dataType(SchemaFieldObjectType.fromTypeList(TypeConstants.ARRAY, itemType))
@@ -247,7 +252,7 @@ private static List processObjectProperty(final String buildi
final var isRequired = ApiTool.checkIfRequired(fieldBody, fieldName);
final SchemaFieldObject field;
if (ApiTool.hasRef(fieldBody)) {
- final var typeName = MapperUtil.getRefSchemaName(fieldBody);
+ final var typeName = MapperUtil.getRefSchemaName(fieldBody, fieldName);
final var refSchema = totalSchemas.get(MapperUtil.getRefSchemaKey(fieldBody));
if (!antiLoopList.contains(typeName) && Objects.nonNull(refSchema) && ApiTool.hasType(refSchema)
&& ApiTool.hasItems(refSchema) || ApiTool.getRefValue(fieldBody).contains(fieldName)) {
@@ -515,7 +520,7 @@ private static List processAdditionalProperties(
.dataType(SchemaFieldObjectType.fromTypeList(TypeConstants.MAP, TypeConstants.OBJECT))
.build());
} else if (ApiTool.hasRef(addPropObj)) {
- final String refSchemaName = MapperUtil.getRef(addPropObj, specFile);
+ final String refSchemaName = MapperUtil.getPojoNameFromRef(addPropObj, specFile, null);
fieldObjectArrayList.add(processRef(fieldName, addPropObj,
SchemaFieldObjectType.fromTypeList(TypeConstants.MAP, refSchemaName), totalSchemas, compositedSchemas,
antiLoopList, specFile, baseDir));
@@ -607,7 +612,7 @@ private static void setFieldType(
} else if (ApiTool.isObject(schemaProperty)) {
var typeObject = ApiTool.getType(schemaProperty);
if (ApiTool.hasRef(schemaProperty)) {
- typeObject = MapperUtil.getRef(schema, specFile);
+ typeObject = MapperUtil.getPojoNameFromRef(schema, specFile, null);
}
field.setImportClass(getImportClass(typeObject));
field.getDataType().setDeepType(typeObject);
@@ -621,7 +626,7 @@ private static String getMapTypeObject(final JsonNode schema, final CommonSpecFi
} else {
final JsonNode additionalProperties = ApiTool.getAdditionalProperties(schema);
if (ApiTool.hasRef(additionalProperties)) {
- type = MapperUtil.getRef(additionalProperties, specFile);
+ type = MapperUtil.getPojoNameFromRef(additionalProperties, specFile, null);
} else if (ApiTool.isObject(schema)) {
final var additionalPropertiesField = SchemaFieldObject
.builder()
@@ -682,7 +687,7 @@ private static Set processAnyOfOneOf(final String buildingSch
for (JsonNode internalSchema : schemaList) {
if (ApiTool.hasRef(internalSchema)) {
- final var schemaName = MapperUtil.getRefSchemaName(internalSchema);
+ final var schemaName = MapperUtil.getRefSchemaName(internalSchema, null);
if (!antiLoopList.contains(schemaName)) {
if (compositedSchemas.containsKey(schemaName)) {
antiLoopList.add(schemaName);
@@ -720,9 +725,9 @@ private static SchemaFieldObject processRef(
.baseName(fieldName)
.dataType(dataType)
.build();
- if (!antiLoopList.contains(MapperUtil.getRefSchemaName(schema))) {
- antiLoopList.add(MapperUtil.getRefSchemaName(schema));
- final String refSchemaName = MapperUtil.getRef(schema, specFile);
+ if (!antiLoopList.contains(MapperUtil.getRefSchemaName(schema, fieldName))) {
+ antiLoopList.add(MapperUtil.getRefSchemaName(schema, fieldName));
+ final String refSchemaName = MapperUtil.getPojoNameFromRef(schema, specFile, fieldName);
setFieldType(field, schema, schema, specFile, refSchemaName);
solveRef(schema, totalSchemas, compositedSchemas, antiLoopList, specFile, baseDir);
@@ -737,11 +742,11 @@ private static SchemaObject solveRef(
final var referredSchema = SchemaUtil.solveRef(ApiTool.getRefValue(schema), totalSchemas, baseDir.resolve(specFile.getFilePath()).getParent());
- final var schemaObject = buildSchemaObject(totalSchemas, MapperUtil.getRefSchemaName(schema), referredSchema,
- antiLoopList, compositedSchemas, MapperUtil.getRefSchemaName(schema), specFile, baseDir);
+ final var schemaObject = buildSchemaObject(totalSchemas, MapperUtil.getRefSchemaName(schema, null), referredSchema,
+ antiLoopList, compositedSchemas, MapperUtil.getRefSchemaName(schema, null), specFile, baseDir);
schemaObject.setEnum(ApiTool.isEnum(referredSchema));
- compositedSchemas.put(MapperUtil.getRefSchemaName(schema), schemaObject);
+ compositedSchemas.put(MapperUtil.getRefSchemaName(schema, null), schemaObject);
return schemaObject;
}
diff --git a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/SchemaUtil.java b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/SchemaUtil.java
index 8a4573b3..3ea2339b 100644
--- a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/SchemaUtil.java
+++ b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/common/tools/SchemaUtil.java
@@ -21,8 +21,10 @@ public static JsonNode solveRef(final String refValue, final Map {
if (ApiTool.hasType(basicSchema)) {
if (validType(ApiTool.getType(basicSchema))) {
- processModel(specFile, modelPackage, basicSchemaMap, overwrite, MapperUtil.getKeySchemaName(schemaName), basicSchema);
+ processModel(specFile, modelPackage, basicSchemaMap, overwrite, chooseRightName(schemaName), basicSchema);
}
} else {
- processModel(specFile, modelPackage, basicSchemaMap, overwrite, MapperUtil.getKeySchemaName(schemaName), basicSchema);
+ processModel(specFile, modelPackage, basicSchemaMap, overwrite, chooseRightName(schemaName), basicSchema);
}
});
}
+ private String chooseRightName(final String schemaName) {
+ String rightName = schemaName;
+ if (!StringUtils.startsWith(schemaName, "Inline")) {
+ rightName = MapperUtil.getKeySchemaName(schemaName);
+ }
+ return rightName;
+ }
+
private boolean validType(final String type) {
return !TypeConstants.NO_PROCESS_TYPE.contains(type);
}
@@ -233,7 +240,7 @@ private void processModel(
}
if (ApiTool.hasRef(basicSchema)) {
- final var refSchema = MapperUtil.getRefSchemaName(basicSchema);
+ final var refSchema = MapperUtil.getRefSchemaName(basicSchema, schemaName);
writeSchemaObject(specFile, refSchema, basicSchemaMap.get(refSchema), basicSchemaMap, modelPackage);
} else if (!ApiTool.isArray(basicSchema) && !TypeConstants.STRING.equalsIgnoreCase(ApiTool.getType(basicSchema))) {
writeSchemaObject(specFile, schemaName, basicSchema, basicSchemaMap, modelPackage);
diff --git a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/openapi/utils/MapperPathUtil.java b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/openapi/utils/MapperPathUtil.java
index 5ec8cb62..fa0c3a9f 100644
--- a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/openapi/utils/MapperPathUtil.java
+++ b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/openapi/utils/MapperPathUtil.java
@@ -298,7 +298,7 @@ private static List buildParameterContent(
.dataType(SchemaFieldObjectType.fromTypeList(inlineParameterPojo))
.importName(inlineParameterPojo)
.build());
- globalObject.getSchemaMap().put(StringCaseUtils.titleToSnakeCase(inlineParameter), parameterSchema);
+ globalObject.getSchemaMap().put(StringCaseUtils.titleToSnakeCase(inlineParameterPojo), parameterSchema);
} else {
parameterObjects.add(builder
.name(parameterName)
@@ -387,7 +387,7 @@ private static String preparePojoName(final String inlineObject, final JsonNode
} else if (ApiTool.isOneOf(schema)) {
pojoName = getPojoName(inlineObject + "OneOf", specFile);
} else if (ApiTool.hasRef(schema)) {
- pojoName = getPojoName(inlineObject + MapperUtil.getRefSchemaName(schema), specFile);
+ pojoName = getPojoName(inlineObject + MapperUtil.getRefSchemaName(schema, null), specFile);
} else {
pojoName = getPojoName(inlineObject, specFile);
}
@@ -401,8 +401,8 @@ private static SchemaFieldObjectType getSchemaType(
SchemaFieldObjectType type = null;
if (ApiTool.hasRef(schema)) {
- final String refSchemaPojoName = MapperUtil.getRef(schema, specFile);
- final JsonNode refSchema = getRefSchema(schema, specFile, globalObject, baseDir);
+ final String refSchemaPojoName = MapperUtil.getPojoNameFromRef(schema, specFile, pojoName);
+ final JsonNode refSchema = getRefSchema(schema, specFile, globalObject, baseDir, pojoName);
type = getSchemaType(refSchema, refSchemaPojoName, specFile, globalObject, baseDir);
} else if (ApiTool.hasAdditionalProperties(schema)) {
type = getMapSchemaType(schema, pojoName, specFile, globalObject, baseDir);
@@ -417,21 +417,25 @@ private static SchemaFieldObjectType getSchemaType(
return type;
}
- private static JsonNode getRefSchema(JsonNode schema, SpecFile specFile, GlobalObject globalObject, Path baseDir) {
- JsonNode refSchema = null;
+ private static JsonNode getRefSchema(JsonNode schema, SpecFile specFile, GlobalObject globalObject, Path baseDir, String inlinePojoName) {
+ JsonNode refSchema;
final String refValue = ApiTool.getRefValue(schema);
if (refValue.contains("schemas")) {
- refSchema = SchemaUtil.solveRef(ApiTool.getRefValue(schema), globalObject.getSchemaMap(),
+ refSchema = SchemaUtil.solveRef(refValue, globalObject.getSchemaMap(),
baseDir.resolve(specFile.getFilePath()).getParent());
} else if (refValue.contains("requestBodies")) {
- refSchema = SchemaUtil.solveRef(ApiTool.getRefValue(schema), globalObject.getRequestBodyMap(),
+ refSchema = SchemaUtil.solveRef(refValue, globalObject.getRequestBodyMap(),
baseDir.resolve(specFile.getFilePath()).getParent());
} else if (refValue.contains("parameters")) {
- refSchema = SchemaUtil.solveRef(ApiTool.getRefValue(schema), globalObject.getParameterMap(),
+ refSchema = SchemaUtil.solveRef(refValue, globalObject.getParameterMap(),
baseDir.resolve(specFile.getFilePath()).getParent());
} else if (refValue.contains("responseBodies")) {
- refSchema = SchemaUtil.solveRef(ApiTool.getRefValue(schema), globalObject.getResponseMap(),
+ refSchema = SchemaUtil.solveRef(refValue, globalObject.getResponseMap(),
baseDir.resolve(specFile.getFilePath()).getParent());
+ } else {
+ refSchema = SchemaUtil.solveRef(refValue, globalObject.getSchemaMap(),
+ baseDir.resolve(specFile.getFilePath()).getParent());
+ globalObject.getSchemaMap().put(inlinePojoName, refSchema);
}
return refSchema;
}
diff --git a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/openapi/utils/OpenApiUtil.java b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/openapi/utils/OpenApiUtil.java
index 40be35a0..11add634 100644
--- a/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/openapi/utils/OpenApiUtil.java
+++ b/multiapi-engine/src/main/java/com/sngular/api/generator/plugin/openapi/utils/OpenApiUtil.java
@@ -27,6 +27,7 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.sngular.api.generator.plugin.common.tools.ApiTool;
+import com.sngular.api.generator.plugin.common.tools.MapperUtil;
import com.sngular.api.generator.plugin.common.tools.StringCaseUtils;
import com.sngular.api.generator.plugin.openapi.exception.FileParseException;
import com.sngular.api.generator.plugin.openapi.parameter.SpecFile;
@@ -130,7 +131,7 @@ private static String readFile(final Path rootFilePath, final String filePath) t
return sb.toString();
}
- public static Map processPaths(final JsonNode openApi, final Map schemaMap) {
+ public static Map processPaths(final JsonNode openApi, final Map schemaMap, SpecFile specFile) {
final var basicJsonNodeMap = new HashMap<>(schemaMap);
for (final var pathElement = openApi.findValue(PATHS).elements(); pathElement.hasNext();) {
@@ -138,7 +139,7 @@ public static Map processPaths(final JsonNode openApi, final M
for (Iterator it = pathDefinition.fieldNames(); it.hasNext();) {
final var pathDefElement = it.next();
if (REST_VERB_SET.contains(pathDefElement)) {
- processPathContent(basicJsonNodeMap, ApiTool.getNode(pathDefinition, pathDefElement));
+ processPathContent(basicJsonNodeMap, ApiTool.getNode(pathDefinition, pathDefElement), specFile);
}
}
}
@@ -146,26 +147,26 @@ public static Map processPaths(final JsonNode openApi, final M
return basicJsonNodeMap;
}
- private static void processPathContent(final HashMap basicJsonNodeMap, final JsonNode operation) {
+ private static void processPathContent(final HashMap basicJsonNodeMap, final JsonNode operation, SpecFile specFile) {
- processParameters(basicJsonNodeMap, operation);
- processRequestBody(basicJsonNodeMap, operation);
- processResponses(basicJsonNodeMap, operation);
+ processParameters(basicJsonNodeMap, operation, specFile);
+ processRequestBody(basicJsonNodeMap, operation, specFile);
+ processResponses(basicJsonNodeMap, operation, specFile);
}
- private static void processRequestBody(final HashMap basicJsonNodeMap, final JsonNode operation) {
+ private static void processRequestBody(final HashMap basicJsonNodeMap, final JsonNode operation, SpecFile specFile) {
if (ApiTool.hasNode(operation, "requestBody") && !operation.at("/requestBody/content").isMissingNode()) {
final var content = operation.at("/requestBody/content");
final var schema = content.findValue("schema");
if (!ApiTool.hasRef(schema)) {
- basicJsonNodeMap.put(StringCaseUtils.titleToSnakeCase("InlineObject" + StringUtils.capitalize(getOperationId(operation))), schema);
+ basicJsonNodeMap.put(StringCaseUtils.titleToSnakeCase(MapperUtil.getPojoName("InlineObject" + StringUtils.capitalize(getOperationId(operation)), specFile)), schema);
} else if (ApiTool.hasItems(schema)) {
- basicJsonNodeMap.put(StringCaseUtils.titleToSnakeCase("InlineObject" + StringUtils.capitalize(ApiTool.getNodeAsString(operation, "operationId"))), ApiTool.getItems(schema));
+ basicJsonNodeMap.put(StringCaseUtils.titleToSnakeCase(MapperUtil.getPojoName("InlineObject" + StringUtils.capitalize(ApiTool.getNodeAsString(operation, "operationId")), specFile)), ApiTool.getItems(schema));
}
}
}
- private static void processResponses(final HashMap basicJsonNodeMap, final JsonNode operation) {
+ private static void processResponses(final HashMap basicJsonNodeMap, final JsonNode operation, SpecFile specFile) {
if (ApiTool.hasNode(operation, "responses")) {
final var responses = ApiTool.getNode(operation, "responses");
for (Iterator> it = responses.fields(); it.hasNext();) {
@@ -174,9 +175,9 @@ private static void processResponses(final HashMap basicJsonNo
final var schemaList = ApiTool.findContentSchemas(response.getValue());
for (var schema : schemaList) {
if (!ApiTool.hasRef(schema) && ApiTool.isObject(schema)) {
- basicJsonNodeMap.put(StringCaseUtils.titleToSnakeCase("InlineResponse" + response.getKey() + StringUtils.capitalize(getOperationId(operation))), schema);
+ basicJsonNodeMap.put(StringCaseUtils.titleToSnakeCase(MapperUtil.getPojoName("InlineResponse" + response.getKey() + StringUtils.capitalize(getOperationId(operation)), specFile)), schema);
} else if (ApiTool.isComposed(schema)) {
- basicJsonNodeMap.put(StringCaseUtils.titleToSnakeCase("InlineResponse" + response.getKey() + StringUtils.capitalize(getOperationId(operation)) + getComposedJsonNodeName(schema)), schema);
+ basicJsonNodeMap.put(StringCaseUtils.titleToSnakeCase(MapperUtil.getPojoName("InlineResponse" + response.getKey() + StringUtils.capitalize(getOperationId(operation)) + getComposedJsonNodeName(schema), specFile)), schema);
}
}
}
@@ -184,13 +185,13 @@ private static void processResponses(final HashMap basicJsonNo
}
}
- private static void processParameters(final HashMap basicJsonNodeMap, final JsonNode operation) {
+ private static void processParameters(final HashMap basicJsonNodeMap, final JsonNode operation, SpecFile specFile) {
if (ApiTool.hasNode(operation, "parameters")) {
for (Iterator it = operation.findValue("parameters").elements(); it.hasNext();) {
final var parameter = it.next();
if (ApiTool.hasNode(parameter, "content")) {
basicJsonNodeMap.putIfAbsent(
- StringCaseUtils.titleToSnakeCase("InlineParameter" + StringUtils.capitalize(getOperationId(operation)) + StringUtils.capitalize(ApiTool.getName(parameter))),
+ StringCaseUtils.titleToSnakeCase(MapperUtil.getPojoName("InlineParameter" + StringUtils.capitalize(getOperationId(operation)) + StringUtils.capitalize(ApiTool.getName(parameter)), specFile)),
ApiTool.getNode(parameter, "schema"));
}
}
diff --git a/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/asyncapi/AsyncApiGeneratorFixtures.java b/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/asyncapi/AsyncApiGeneratorFixtures.java
index a0196caa..15dd0a9e 100644
--- a/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/asyncapi/AsyncApiGeneratorFixtures.java
+++ b/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/asyncapi/AsyncApiGeneratorFixtures.java
@@ -19,6 +19,8 @@
import java.util.List;
import java.util.function.Function;
+import static java.util.Collections.singletonList;
+
public class AsyncApiGeneratorFixtures {
static final List TEST_FILE_GENERATION = List.of(
@@ -412,6 +414,18 @@ public class AsyncApiGeneratorFixtures {
.build())
.build());
+ static final List TEST_REFERENCE_FROM_LOCAL_ISSUE =
+ List.of(
+ SpecFile.builder()
+ .filePath("src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/event-api.yml")
+ .consumer(
+ OperationParameterObject.builder()
+ .ids("userSignedUp")
+ .apiPackage("com.github.issue.listener")
+ .modelPackage("com.github.issue.model")
+ .build())
+ .build());
+
static final String TARGET = "target";
static final String GENERATED = "generated/";
@@ -1129,4 +1143,36 @@ static Function validateTestSubObjectSameName() {
&& modelTest(path, expectedConsumerModelSchemaFiles, DEFAULT_CONSUMER_MODEL_FOLDER)
&& modelTest(path, expectedProducerModelSchemaFiles, DEFAULT_PRODUCER_MODEL_FOLDER);
}
+
+ static Function validateTestReferenceFromLocalIssue() {
+
+ final String DEFAULT_COMMON_FOLDER = "generated";
+
+ final String DEFAULT_CONSUMER_FOLDER = DEFAULT_COMMON_FOLDER + "/com/github/issue/listener";
+
+ final String DEFAULT_CONSUMER_MODEL_FOLDER = DEFAULT_COMMON_FOLDER + "/com/github/issue/model";
+
+ final String COMMON_PATH = "asyncapigenerator/testReferenceFromLocalIssue/";
+
+ final String ASSETS_PATH = COMMON_PATH + "assets/";
+
+ final List expectedConsumerFiles =
+ List.of(
+ ASSETS_PATH + "IUserSignedUp.java",
+ ASSETS_PATH + "Subscriber.java");
+
+ final List expectedConsumerModelSchemaFiles =
+ singletonList(ASSETS_PATH + "/UserMessage.java");
+
+ return path ->
+ commonTest(
+ path,
+ expectedConsumerFiles,
+ Collections.emptyList(),
+ DEFAULT_CONSUMER_FOLDER,
+ null,
+ Collections.emptyList(),
+ null)
+ && modelTest(path, expectedConsumerModelSchemaFiles, DEFAULT_CONSUMER_MODEL_FOLDER);
+ }
}
diff --git a/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/asyncapi/AsyncApiGeneratorTest.java b/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/asyncapi/AsyncApiGeneratorTest.java
index c94c8663..08913bc8 100644
--- a/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/asyncapi/AsyncApiGeneratorTest.java
+++ b/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/asyncapi/AsyncApiGeneratorTest.java
@@ -79,7 +79,9 @@ static Stream fileSpecToProcess() {
Arguments.of("TestFileGenerationWithKafkaBindings", AsyncApiGeneratorFixtures.TEST_FILE_GENERATION_WITH_KAFKA_BINDINGS,
AsyncApiGeneratorFixtures.validateTestFileGenerationWithKafkaBindings()),
Arguments.of("TestSubObjectSameName", AsyncApiGeneratorFixtures.TEST_SUB_OBJECT_SAME_NAME,
- AsyncApiGeneratorFixtures.validateTestSubObjectSameName()));
+ AsyncApiGeneratorFixtures.validateTestSubObjectSameName()),
+ Arguments.of("TestReferenceFromLocalIssue", AsyncApiGeneratorFixtures.TEST_REFERENCE_FROM_LOCAL_ISSUE,
+ AsyncApiGeneratorFixtures.validateTestReferenceFromLocalIssue()));
}
@ParameterizedTest(name = "Test {index} - Process File Spec for case {0}")
diff --git a/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorFixtures.java b/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorFixtures.java
index ec85ded4..1a1bffc1 100644
--- a/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorFixtures.java
+++ b/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorFixtures.java
@@ -478,6 +478,18 @@ public final class OpenApiGeneratorFixtures {
.build()
);
+ static final List TEST_REFERENCE_FILE_NO_COMPONENTS = List.of(
+ SpecFile
+ .builder()
+ .filePath("openapigenerator/testReferenceFileNoComponents/api-test.yml")
+ .apiPackage("com.sngular.multifileplugin.testreferencefilenocomponents")
+ .modelPackage("com.sngular.multifileplugin.testreferencefilenocomponents.model")
+ .clientPackage("com.sngular.multifileplugin.testreferencefilenocomponents.client")
+ .modelNameSuffix("DTO")
+ .useLombokModelAnnotation(true)
+ .build()
+ );
+
static final List TEST_QUERY_PARAM = List.of(
SpecFile
.builder()
@@ -1518,6 +1530,25 @@ static Function validateReferenceFile() {
return path -> commonTest(path, expectedTestApiFiles, expectedTestApiModelFiles, DEFAULT_TARGET_API, DEFAULT_MODEL_API, Collections.emptyList(), DEFAULT_EXCEPTION_API);
}
+
+ static Function validateReferenceFileNoComponents() {
+ final String DEFAULT_TARGET_API = "generated/com/sngular/multifileplugin/testReferenceFileNoComponents";
+
+ final String DEFAULT_MODEL_API = "generated/com/sngular/multifileplugin/testReferenceFileNoComponents/model";
+
+ final String DEFAULT_EXCEPTION_API = "generated/com/sngular/multifileplugin/testReferenceFileNoComponents/model/exception";
+
+ final List expectedTestApiFiles = List.of(
+ "openapigenerator/testReferenceFileNoComponents/assets/TestApi.java"
+ );
+
+ final List expectedTestApiModelFiles = List.of(
+ "openapigenerator/testReferenceFileNoComponents/assets/InlineResponse200TestFileDTO.java"
+ );
+
+ return path -> commonTest(path, expectedTestApiFiles, expectedTestApiModelFiles, DEFAULT_TARGET_API, DEFAULT_MODEL_API, Collections.emptyList(), DEFAULT_EXCEPTION_API);
+ }
+
static Function validateQueryParam() {
final String DEFAULT_TARGET_API = "generated/com/sngular/multifileplugin/testQueryParam";
diff --git a/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorTest.java b/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorTest.java
index 5bfc420e..24b187c8 100644
--- a/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorTest.java
+++ b/multiapi-engine/src/test/java/com/sngular/api/generator/plugin/openapi/OpenApiGeneratorTest.java
@@ -117,6 +117,8 @@ static Stream fileSpecToProcess() {
OpenApiGeneratorFixtures.validateListString()),
Arguments.of("testReferenceFile", OpenApiGeneratorFixtures.TEST_REFERENCE_FILE,
OpenApiGeneratorFixtures.validateReferenceFile()),
+ Arguments.of("testReferenceFileNoComponents", OpenApiGeneratorFixtures.TEST_REFERENCE_FILE_NO_COMPONENTS,
+ OpenApiGeneratorFixtures.validateReferenceFileNoComponents()),
Arguments.of("testQueryParam", OpenApiGeneratorFixtures.TEST_QUERY_PARAM,
OpenApiGeneratorFixtures.validateQueryParam()),
Arguments.of("testApiWithNoComponents", OpenApiGeneratorFixtures.TEST_API_WITH_NO_COMPONENTS,
diff --git a/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/assets/IUserSignedUp.java b/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/assets/IUserSignedUp.java
new file mode 100644
index 00000000..7974490b
--- /dev/null
+++ b/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/assets/IUserSignedUp.java
@@ -0,0 +1,8 @@
+package com.github.issue.listener;
+
+import com.github.issue.model.UserMessage;
+
+public interface IUserSignedUp {
+
+ void userSignedUp(final UserMessage value);
+}
\ No newline at end of file
diff --git a/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/assets/Subscriber.java b/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/assets/Subscriber.java
new file mode 100644
index 00000000..f1c7b6a2
--- /dev/null
+++ b/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/assets/Subscriber.java
@@ -0,0 +1,24 @@
+package com.github.issue.listener;
+
+import java.util.function.Consumer;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import com.github.issue.model.UserMessage;
+
+@Configuration
+public class Subscriber {
+
+ private final IUserSignedUp userSignedUp;
+
+ protected Subscriber(final IUserSignedUp userSignedUp) {
+ this.userSignedUp = userSignedUp;
+ }
+
+ @Bean
+ public Consumer userSignedUp() {
+ return value -> userSignedUp.userSignedUp(value);
+ }
+
+
+}
diff --git a/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/assets/UserMessage.java b/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/assets/UserMessage.java
new file mode 100644
index 00000000..f3cabcb2
--- /dev/null
+++ b/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/assets/UserMessage.java
@@ -0,0 +1,94 @@
+package com.github.issue.model;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+
+@JsonDeserialize(builder = UserMessage.UserMessageBuilder.class)
+public class UserMessage {
+
+ @JsonProperty(value ="firstName")
+ private String firstName;
+ @JsonProperty(value ="lastName")
+ private String lastName;
+
+ private UserMessage(UserMessageBuilder builder) {
+ this.firstName = builder.firstName;
+ this.lastName = builder.lastName;
+
+ }
+
+ public static UserMessage.UserMessageBuilder builder() {
+ return new UserMessage.UserMessageBuilder();
+ }
+
+ @JsonPOJOBuilder(buildMethodName = "build", withPrefix = "")
+ public static class UserMessageBuilder {
+
+ private String firstName;
+ private String lastName;
+
+ public UserMessage.UserMessageBuilder firstName(String firstName) {
+ this.firstName = firstName;
+ return this;
+ }
+
+ public UserMessage.UserMessageBuilder lastName(String lastName) {
+ this.lastName = lastName;
+ return this;
+ }
+
+ public UserMessage build() {
+ UserMessage userMessage = new UserMessage(this);
+ return userMessage;
+ }
+ }
+
+ @Schema(name = "firstName", required = false)
+ public String getFirstName() {
+ return firstName;
+ }
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ @Schema(name = "lastName", required = false)
+ public String getLastName() {
+ return lastName;
+ }
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ UserMessage userMessage = (UserMessage) o;
+ return Objects.equals(this.firstName, userMessage.firstName) && Objects.equals(this.lastName, userMessage.lastName);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(firstName, lastName);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("UserMessage{");
+ sb.append(" firstName:").append(firstName).append(",");
+ sb.append(" lastName:").append(lastName);
+ sb.append("}");
+ return sb.toString();
+ }
+
+
+}
diff --git a/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/event-api.yml b/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/event-api.yml
new file mode 100644
index 00000000..80151909
--- /dev/null
+++ b/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/event-api.yml
@@ -0,0 +1,32 @@
+# asyncapi.yaml
+asyncapi: 2.6.0
+info:
+ title: Account Service
+ version: "1.0.0"
+channels:
+ user/signedup:
+ subscribe:
+ operationId: userSignedUp
+ message:
+ $ref: "#/components/messages/UserSignedUp"
+components:
+ messages:
+ UserSignedUp:
+ payload:
+ # this leads to the error
+ # `Cannot invoke "com.fasterxml.jackson.databind.JsonNode.get(String)" because the return value of "com.fasterxml.jackson.databind.JsonNode.findValue(String)" is null`:
+ $ref: "./user-message.yml"
+ schemas:
+ user:
+ # this works:
+ type: object
+ properties:
+ firstName:
+ type: string
+ description: "foo"
+ lastName:
+ type: string
+ description: "bar"
+ # this leads to the error
+ # `Cannot invoke "com.fasterxml.jackson.databind.JsonNode.has(String)" because "properties" is null`:
+ $ref: "./user.yml"
diff --git a/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/user-message.yml b/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/user-message.yml
new file mode 100644
index 00000000..fb21a56c
--- /dev/null
+++ b/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/user-message.yml
@@ -0,0 +1,8 @@
+type: object
+properties:
+ firstName:
+ type: string
+ description: "foo"
+ lastName:
+ type: string
+ description: "bar"
\ No newline at end of file
diff --git a/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/user.yml b/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/user.yml
new file mode 100644
index 00000000..fb21a56c
--- /dev/null
+++ b/multiapi-engine/src/test/resources/asyncapigenerator/testReferenceFromLocalIssue/user.yml
@@ -0,0 +1,8 @@
+type: object
+properties:
+ firstName:
+ type: string
+ description: "foo"
+ lastName:
+ type: string
+ description: "bar"
\ No newline at end of file
diff --git a/multiapi-engine/src/test/resources/openapigenerator/testReferenceFileNoComponents/api-test.yml b/multiapi-engine/src/test/resources/openapigenerator/testReferenceFileNoComponents/api-test.yml
new file mode 100644
index 00000000..c430f184
--- /dev/null
+++ b/multiapi-engine/src/test/resources/openapigenerator/testReferenceFileNoComponents/api-test.yml
@@ -0,0 +1,19 @@
+openapi: 3.0.2
+info:
+ title: Testing example file
+ version: 1.0.0
+servers:
+- url: http://localhost/v1
+paths:
+ /test:
+ get:
+ tags:
+ - test
+ operationId: testFile
+ responses:
+ '200':
+ description: Some schema from another file
+ content:
+ application/json:
+ schema:
+ $ref: './assets/path.yml'
diff --git a/multiapi-engine/src/test/resources/openapigenerator/testReferenceFileNoComponents/assets/InlineResponse200TestFileDTO.java b/multiapi-engine/src/test/resources/openapigenerator/testReferenceFileNoComponents/assets/InlineResponse200TestFileDTO.java
new file mode 100644
index 00000000..dc546002
--- /dev/null
+++ b/multiapi-engine/src/test/resources/openapigenerator/testReferenceFileNoComponents/assets/InlineResponse200TestFileDTO.java
@@ -0,0 +1,22 @@
+package com.sngular.multifileplugin.testreferencefilenocomponents.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Builder;
+import lombok.Value;
+import lombok.extern.jackson.Jacksonized;
+
+@Value
+public class InlineResponse200TestFileDTO {
+
+ @JsonProperty(value ="something")
+ private String something;
+
+
+ @Builder
+ @Jacksonized
+ private InlineResponse200TestFileDTO(String something) {
+ this.something = something;
+
+ }
+
+}
diff --git a/multiapi-engine/src/test/resources/openapigenerator/testReferenceFileNoComponents/assets/TestApi.java b/multiapi-engine/src/test/resources/openapigenerator/testReferenceFileNoComponents/assets/TestApi.java
new file mode 100644
index 00000000..963b986b
--- /dev/null
+++ b/multiapi-engine/src/test/resources/openapigenerator/testReferenceFileNoComponents/assets/TestApi.java
@@ -0,0 +1,45 @@
+package com.sngular.multifileplugin.testreferencefilenocomponents;
+
+import java.util.Optional;
+import java.util.List;
+import java.util.Map;
+import javax.validation.Valid;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import org.springframework.http.MediaType;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.context.request.NativeWebRequest;
+
+import com.sngular.multifileplugin.testreferencefilenocomponents.model.InlineResponse200TestFileDTO;
+
+public interface TestApi {
+
+ /**
+ * GET /test
+ * @return Some schema from another file; (status code 200)
+ */
+
+ @Operation(
+ operationId = "testFile",
+ tags = {"test"},
+ responses = {
+ @ApiResponse(responseCode = "200", description = "Some schema from another file", content = @Content(mediaType = "application/json", schema = @Schema(implementation = InlineResponse200TestFileDTO.class)))
+ }
+ )
+ @RequestMapping(
+ method = RequestMethod.GET,
+ value = "/test",
+ produces = {"application/json"}
+ )
+
+ default ResponseEntity testFile() {
+ return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+ }
+
+}
diff --git a/multiapi-engine/src/test/resources/openapigenerator/testReferenceFileNoComponents/assets/path.yml b/multiapi-engine/src/test/resources/openapigenerator/testReferenceFileNoComponents/assets/path.yml
new file mode 100644
index 00000000..4a7e85f0
--- /dev/null
+++ b/multiapi-engine/src/test/resources/openapigenerator/testReferenceFileNoComponents/assets/path.yml
@@ -0,0 +1,4 @@
+type: object
+properties:
+ something:
+ type: string
diff --git a/scs-multiapi-gradle-plugin/build.gradle b/scs-multiapi-gradle-plugin/build.gradle
index 56d55021..c030d69b 100644
--- a/scs-multiapi-gradle-plugin/build.gradle
+++ b/scs-multiapi-gradle-plugin/build.gradle
@@ -20,7 +20,7 @@ repositories {
}
group = 'com.sngular'
-version = '6.0.2'
+version = '6.0.3'
def SCSMultiApiPluginGroupId = group
def SCSMultiApiPluginVersion = version
@@ -30,7 +30,7 @@ dependencies {
shadow localGroovy()
shadow gradleApi()
- implementation 'com.sngular:multiapi-engine:6.0.2'
+ implementation 'com.sngular:multiapi-engine:6.0.3'
testImplementation 'org.assertj:assertj-core:3.24.2'
testImplementation 'com.puppycrawl.tools:checkstyle:10.12.3'
}
@@ -98,7 +98,7 @@ testing {
integrationTest(JvmTestSuite) {
dependencies {
- implementation 'com.sngular:scs-multiapi-gradle-plugin:6.0.2'
+ implementation 'com.sngular:scs-multiapi-gradle-plugin:6.0.3'
implementation 'org.assertj:assertj-core:3.24.2'
}
diff --git a/scs-multiapi-maven-plugin/pom.xml b/scs-multiapi-maven-plugin/pom.xml
index af9ebc37..c2404f49 100644
--- a/scs-multiapi-maven-plugin/pom.xml
+++ b/scs-multiapi-maven-plugin/pom.xml
@@ -4,7 +4,7 @@
com.sngular
scs-multiapi-maven-plugin
- 6.0.2
+ 6.0.3
maven-plugin
AsyncApi - OpenApi Code Generator Maven Plugin
@@ -271,7 +271,7 @@
com.sngular
multiapi-engine
- 6.0.2
+ 6.0.3
org.apache.maven