From 8aa2a5ce7522efbdfe944550a539dc2b55145802 Mon Sep 17 00:00:00 2001 From: TharmiganK Date: Fri, 15 Dec 2023 16:26:46 +0530 Subject: [PATCH] Fix bad sad error --- .../converter/service/OpenAPIComponentMapper.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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;