Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Set UnresolvedReference=true for schemas with OpenAPIReference objects #175

Merged
merged 2 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Microsoft.OpenApi.OData.Reader/Common/EdmModelHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ internal static OpenApiSchema GetDerivedTypesReferenceSchema(IEdmStructuredType

OpenApiSchema baseTypeSchema = new()
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Expand All @@ -49,6 +50,7 @@ internal static OpenApiSchema GetDerivedTypesReferenceSchema(IEdmStructuredType
{
OpenApiSchema derivedTypeSchema = new()
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,112 +283,127 @@ public static OpenApiSchema CreateSchema(this ODataContext context, IEdmPrimitiv
Type = ReferenceType.Schema,
Id = "Edm.Geography"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeographyPoint:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeographyPoint"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeographyLineString:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeographyLineString"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeographyPolygon:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeographyPolygon"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeographyCollection:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeographyCollection"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeographyMultiPolygon:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeographyMultiPolygon"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeographyMultiLineString:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeographyMultiLineString"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeographyMultiPoint:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeographyMultiPoint"
};
schema.UnresolvedReference = true;
break;

case EdmPrimitiveTypeKind.Geometry: // Geometry
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.Geometry"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeometryPoint:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeometryPoint"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeometryLineString:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeometryLineString"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeometryPolygon:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeometryPolygon"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeometryCollection:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeometryCollection"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeometryMultiPolygon:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeometryMultiPolygon"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeometryMultiLineString:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeometryMultiLineString"
};
schema.UnresolvedReference = true;
break;
case EdmPrimitiveTypeKind.GeometryMultiPoint:
schema.Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = "Edm.GeometryMultiPoint"
};
schema.UnresolvedReference = true;
break;

case EdmPrimitiveTypeKind.None:
Expand All @@ -414,6 +429,7 @@ private static OpenApiSchema CreateEnumTypeSchema(this ODataContext context, IEd
{
new OpenApiSchema
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Expand All @@ -431,6 +447,7 @@ private static OpenApiSchema CreateEnumTypeSchema(this ODataContext context, IEd
Type = ReferenceType.Schema,
Id = typeReference.Definition.FullTypeName()
};
schema.UnresolvedReference = true;
}

return schema;
Expand All @@ -455,6 +472,7 @@ private static OpenApiSchema CreateStructuredTypeSchema(this ODataContext contex
{
new OpenApiSchema
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Expand All @@ -472,6 +490,7 @@ private static OpenApiSchema CreateStructuredTypeSchema(this ODataContext contex
Type = ReferenceType.Schema,
Id = typeReference.Definition.FullTypeName()
};
schema.UnresolvedReference = true;
}

return schema;
Expand All @@ -492,6 +511,7 @@ private static OpenApiSchema CreateTypeDefinitionSchema(this ODataContext contex
{
new OpenApiSchema
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Expand All @@ -509,6 +529,7 @@ private static OpenApiSchema CreateTypeDefinitionSchema(this ODataContext contex
Type = ReferenceType.Schema,
Id = reference.Definition.FullTypeName()
};
schema.UnresolvedReference = true;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static OpenApiSchema CreateErrorSchema()
"error",
new OpenApiSchema
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Expand Down Expand Up @@ -130,6 +131,7 @@ public static OpenApiSchema CreateErrorMainSchema()
Type = "array",
Items = new OpenApiSchema
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Expand All @@ -142,6 +144,7 @@ public static OpenApiSchema CreateErrorMainSchema()
"innererror",
new OpenApiSchema
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public static OpenApiParameter CreateTop(this ODataContext context, IEdmVocabula
{
return new OpenApiParameter
{
UnresolvedReference = true,
Reference = new OpenApiReference { Type = ReferenceType.Parameter, Id = "top" }
};
}
Expand All @@ -255,6 +256,7 @@ public static OpenApiParameter CreateSkip(this ODataContext context, IEdmVocabul
{
return new OpenApiParameter
{
UnresolvedReference = true,
Reference = new OpenApiReference { Type = ReferenceType.Parameter, Id = "skip" }
};
}
Expand All @@ -278,6 +280,7 @@ public static OpenApiParameter CreateSearch(this ODataContext context, IEdmVocab
{
return new OpenApiParameter
{
UnresolvedReference = true,
Reference = new OpenApiReference { Type = ReferenceType.Parameter, Id = "search" }
};
}
Expand All @@ -301,6 +304,7 @@ public static OpenApiParameter CreateCount(this ODataContext context, IEdmVocabu
{
return new OpenApiParameter
{
UnresolvedReference = true,
Reference = new OpenApiReference { Type = ReferenceType.Parameter, Id = "count" }
};
}
Expand All @@ -324,6 +328,7 @@ public static OpenApiParameter CreateFilter(this ODataContext context, IEdmVocab
{
return new OpenApiParameter
{
UnresolvedReference = true,
Reference = new OpenApiReference { Type = ReferenceType.Parameter, Id = "filter" }
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ internal static class OpenApiResponseGenerator
{ Constants.StatusCodeDefault,
new OpenApiResponse
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Response,
Expand All @@ -34,6 +35,7 @@ internal static class OpenApiResponseGenerator
{ Constants.StatusCode204, new OpenApiResponse { Description = "Success"} },
{ Constants.StatusCodeClass4XX, new OpenApiResponse
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Response,
Expand All @@ -43,6 +45,7 @@ internal static class OpenApiResponseGenerator
},
{ Constants.StatusCodeClass5XX, new OpenApiResponse
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Response,
Expand Down Expand Up @@ -222,6 +225,7 @@ private static OpenApiResponse CreateCollectionResponse(string typeName)
{
Schema = new OpenApiSchema
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Expand All @@ -238,6 +242,7 @@ private static OpenApiResponse CreateCountResponse()
{
OpenApiSchema schema = new()
{
UnresolvedReference = true,
Reference = new() {
Type = ReferenceType.Schema,
Id = Constants.DollarCountSchemaName
Expand Down Expand Up @@ -272,6 +277,7 @@ private static OpenApiResponse CreateErrorResponse()
{
Schema = new OpenApiSchema
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ private static OpenApiSchema CreateCollectionSchema(ODataContext context, IEdmSt
{
schema = new OpenApiSchema
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Expand Down Expand Up @@ -407,6 +408,7 @@ private static OpenApiSchema CreateStructuredTypeSchema(this ODataContext contex
// 1. a JSON Reference to the Schema Object of the base type
new OpenApiSchema
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static IEnumerable<OpenApiSecurityRequirement> CreateSecurityRequirements
[
new OpenApiSecurityScheme
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Expand Down Expand Up @@ -70,6 +71,7 @@ public static IEnumerable<OpenApiSecurityRequirement> CreateSecurityRequirements
[
new OpenApiSecurityScheme
{
UnresolvedReference = true,
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Expand Down
Loading