diff --git a/openapi-bal-service/src/main/java/io/ballerina/openapi/converter/service/OpenAPIComponentMapper.java b/openapi-bal-service/src/main/java/io/ballerina/openapi/converter/service/OpenAPIComponentMapper.java index e5bcb2abf..adaaf969f 100644 --- a/openapi-bal-service/src/main/java/io/ballerina/openapi/converter/service/OpenAPIComponentMapper.java +++ b/openapi-bal-service/src/main/java/io/ballerina/openapi/converter/service/OpenAPIComponentMapper.java @@ -102,6 +102,9 @@ public void createComponentSchema(Map schema, TypeSymbol typeSym } TypeReferenceTypeSymbol typeRef = (TypeReferenceTypeSymbol) typeSymbol; TypeSymbol type = typeRef.typeDescriptor(); + if (type instanceof TypeReferenceTypeSymbol && isBuiltInSubTypes((TypeReferenceTypeSymbol) type)) { + type = ((TypeReferenceTypeSymbol) type).typeDescriptor(); + } if (type.typeKind() == TypeDescKind.INTERSECTION) { type = excludeReadonlyIfPresent(type); @@ -113,10 +116,6 @@ public void createComponentSchema(Map schema, TypeSymbol typeSym handleRecordTypeSymbol((RecordTypeSymbol) type, schema, componentName, apiDocs); break; case TYPE_REFERENCE: - if (isBuiltInSubTypes((TypeReferenceTypeSymbol) type)) { - createComponentSchema(schema, ((TypeReferenceTypeSymbol) type).typeDescriptor()); - break; - } schema.put(componentName, new ObjectSchema().$ref(ConverterCommonUtils.unescapeIdentifier( type.getName().orElseThrow().trim()))); components.setSchemas(schema); @@ -127,11 +126,17 @@ public void createComponentSchema(Map schema, TypeSymbol typeSym } break; case STRING: - schema.put(componentName, new StringSchema().description(typeDoc)); + case STRING_CHAR: + Schema stringSchema = new StringSchema().description(typeDoc); + schema.put(componentName, stringSchema); components.setSchemas(schema); break; case JSON: case XML: + case XML_ELEMENT: + case XML_PROCESSING_INSTRUCTION: + case XML_TEXT: + case XML_COMMENT: schema.put(componentName, new ObjectSchema().description(typeDoc)); components.setSchemas(schema); break;