Skip to content

Commit

Permalink
Merge pull request #1466 from aneeshafedo/intersection_update
Browse files Browse the repository at this point in the history
Support new changes in the semantics of intersection
  • Loading branch information
rdulmina committed Jul 19, 2023
2 parents 96e88ba + 1589a95 commit 1a419e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ private ObjectSchema generateObjectSchemaFromRecordFields(Map<String, Schema> sc
}
TypeDescKind fieldTypeKind = field.getValue().typeDescriptor().typeKind();
String type = fieldTypeKind.toString().toLowerCase(Locale.ENGLISH);

if (fieldTypeKind == TypeDescKind.INTERSECTION) {
TypeSymbol readOnlyExcludedType = excludeReadonlyIfPresent(field.getValue().typeDescriptor());
type = readOnlyExcludedType.typeKind().toString().toLowerCase(Locale.ENGLISH);
}

Schema property = ConverterCommonUtils.getOpenApiSchema(type);

if (fieldTypeKind == TypeDescKind.TYPE_REFERENCE) {
Expand Down Expand Up @@ -406,6 +412,9 @@ private Schema handleUnionType(UnionTypeSymbol unionType, Schema property, Strin
List<Schema> properties = new ArrayList<>();
boolean nullable = false;
for (TypeSymbol union : unionTypes) {
if (union.typeKind() == TypeDescKind.INTERSECTION) {
union = excludeReadonlyIfPresent(union);
}
if (union.typeKind() == TypeDescKind.NIL) {
nullable = true;
} else if (union.typeKind() == TypeDescKind.TYPE_REFERENCE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,9 @@ private void handleReferenceResponse(OperationAdaptor operationAdaptor, SimpleNa
} else if (typeSymbol.typeKind() == TypeDescKind.TYPE_REFERENCE) {
TypeReferenceTypeSymbol typeReferenceTypeSymbol = (TypeReferenceTypeSymbol) typeSymbol;
TypeSymbol referredTypeSymbol = typeReferenceTypeSymbol.typeDescriptor();
if (referredTypeSymbol.typeKind() == TypeDescKind.INTERSECTION) {
referredTypeSymbol = componentMapper.excludeReadonlyIfPresent(referredTypeSymbol);
}
String referenceName = referenceNode.name().toString().trim();
String referredTypeName = referredTypeSymbol.getName().isPresent() ?
referredTypeSymbol.getName().get() : "";
Expand Down

0 comments on commit 1a419e9

Please sign in to comment.