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

Include correct list of discriminator information #222

Merged
merged 5 commits into from
May 30, 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
Original file line number Diff line number Diff line change
Expand Up @@ -436,23 +436,21 @@ private static OpenApiSchema CreateStructuredTypeSchema(this ODataContext contex
// The discriminator object is added to structured types which have derived types.
OpenApiDiscriminator discriminator = null;
if (context.Settings.EnableDiscriminatorValue && derivedTypes.Any() && structuredType.BaseType != null)
{
string v3RefIdentifier = new OpenApiSchema
{
Reference = new OpenApiReference
{
Dictionary<string, string> mapping = derivedTypes
.ToDictionary(x => $"#{x.FullTypeName()}", x => new OpenApiSchema
{
Type = ReferenceType.Schema,
Id = structuredType.FullTypeName()
}
}.Reference.ReferenceV3;
Reference = new OpenApiReference
{
Type = ReferenceType.Schema,
Id = x.FullTypeName()
}
}.Reference.ReferenceV3);

discriminator = new OpenApiDiscriminator
{
PropertyName = "@odata.type",
Mapping = new Dictionary<string, string>
{
{"#" + structuredType.FullTypeName(), v3RefIdentifier }
}
Mapping = mapping
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,14 @@
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<PackageId>Microsoft.OpenApi.OData</PackageId>
<SignAssembly>true</SignAssembly>
<Version>1.0.10</Version>
<Version>1.0.11-preview1</Version>
<Description>This package contains the codes you need to convert OData CSDL to Open API Document of Model.</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>Microsoft OpenApi OData EDM</PackageTags>
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET.OData</RepositoryUrl>
<PackageReleaseNotes>
- Adds support for reading custom attributes #192
- Adds support for OpenApiLinks for actions and functions #74
- Maps operation summaries to operation descriptions and CSDL description annotations to operation LongDescription #206
- Fixes the response type of functions returning Edm.Stream to use application/octet-stream #200
- Fixes the generation of ODataTypeCast paths #199
- Adds path items for properties of complex type. #176, #15
- Describes errors on error response codes instead of default. #172, #165, #193
- Fixes a bug where reference objects are not created correctly. #171
- Adds support for enum values descriptions. #164
- Declares path parameters on path item instead of operation. #159
- Multiple fixes on navigation properties path items expansion. #151, #123
- Multiple fixes for descriptions. #154
- Fixes a bug where URL templates would be missing quotes for string parameters. #140
- Fixes description of operations of primitive types. #126
- Adds support for OData cast segments in path items generation. #123
- Fixes the response descriptions for functions that return a collection. #122
- Fixes structured and collection-valued parameters of functions. #203
- Adds support for discriminator property in inheritance. #118
- Sets deprecated for operations that are generated from deprecated types/singletons/entitysets/properties in the model. #113
- Aligns target version to netframework2.0. #139
</PackageReleaseNotes>
- Adds list of all derived types for discriminator mapping #219
</PackageReleaseNotes>
<AssemblyName>Microsoft.OpenApi.OData.Reader</AssemblyName>
<AssemblyOriginatorKeyFile>..\..\tool\Microsoft.OpenApi.OData.snk</AssemblyOriginatorKeyFile>
<OutputPath Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">..\..\bin\Debug\</OutputPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,23 @@ public void CreateStructuredTypeSchemaWithDiscriminatorValueEnabledReturnsCorrec
""discriminator"": {
""propertyName"": ""@odata.type"",
""mapping"": {
""#microsoft.graph.directoryObject"": ""#/components/schemas/microsoft.graph.directoryObject""
""#microsoft.graph.user"": ""#/components/schemas/microsoft.graph.user"",
""#microsoft.graph.group"": ""#/components/schemas/microsoft.graph.group"",
""#microsoft.graph.device"": ""#/components/schemas/microsoft.graph.device"",
""#microsoft.graph.application"": ""#/components/schemas/microsoft.graph.application"",
""#microsoft.graph.servicePrincipal"": ""#/components/schemas/microsoft.graph.servicePrincipal"",
""#microsoft.graph.policyBase"": ""#/components/schemas/microsoft.graph.policyBase"",
""#microsoft.graph.extensionProperty"": ""#/components/schemas/microsoft.graph.extensionProperty"",
""#microsoft.graph.endpoint"": ""#/components/schemas/microsoft.graph.endpoint"",
""#microsoft.graph.resourceSpecificPermissionGrant"": ""#/components/schemas/microsoft.graph.resourceSpecificPermissionGrant"",
""#microsoft.graph.administrativeUnit"": ""#/components/schemas/microsoft.graph.administrativeUnit"",
""#microsoft.graph.contract"": ""#/components/schemas/microsoft.graph.contract"",
""#microsoft.graph.directoryObjectPartnerReference"": ""#/components/schemas/microsoft.graph.directoryObjectPartnerReference"",
""#microsoft.graph.directoryRole"": ""#/components/schemas/microsoft.graph.directoryRole"",
""#microsoft.graph.directoryRoleTemplate"": ""#/components/schemas/microsoft.graph.directoryRoleTemplate"",
""#microsoft.graph.directorySettingTemplate"": ""#/components/schemas/microsoft.graph.directorySettingTemplate"",
""#microsoft.graph.organization"": ""#/components/schemas/microsoft.graph.organization"",
""#microsoft.graph.orgContact"": ""#/components/schemas/microsoft.graph.orgContact""
}
}
}
Expand Down