OpenAPI.NET.OData icon indicating copy to clipboard operation
OpenAPI.NET.OData copied to clipboard

When ReadByKeyRestrictions is present with Readable=false value, the path entry is still emitted in the output JSON document with empty body

Open garegina opened this issue 4 years ago • 2 comments

Short summary (3-5 sentences) describing the issue.

Assemblies affected

Which assemblies and versions are known to be affected?

The simplest set of steps to reproduce the issue. If possible, reference a commit that demonstrates the issue.

For an entity set, make it readable, however add restriction so that it is not readable by key, in other words, you want to allow the client to call GET ALL API, but there is no GET ONE API implemented for them:

            <Annotation Term="Org.OData.Capabilities.V1.ReadRestrictions">
                <Record>
                    <PropertyValue Property="Readable" Bool="true" />
                    <PropertyValue Property="ReadByKeyRestrictions">
                        <Record>
                            <PropertyValue Property="Readable" Bool="false" />
                        </Record>
                    </PropertyValue>
                </Record>
            </Annotation>

Or in the code, this is how to accomplish it with Microsoft.OData.Builder library: entitySetConfiguration.HasReadRestrictions().IsReadable(true).HasReadByKeyRestrictions(new ReadByKeyRestrictionsTypeConfiguration().IsReadable(false));

Here is also the code that generates the document IEdmModel model = // defined somewhere.

        OpenApiConvertSettings settings = new OpenApiConvertSettings();
        settings.EnablePagination = true;
        settings.ShowSchemaExamples = true;
        settings.VerifyEdmModel = true;
        OpenApiDocument document = model.ConvertToOpenApi(settings);
        return document.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);

Expected result

The final JSON document should not contain a path entry that corresponds to GET by Key request

What would happen if there wasn't a bug.

Actual result

The final JSON document contains a path entry that corresponds to GET by Key request even though the restriction was added to EDM model.

The following entry is added to the Paths with empty body ({ })

"/EntitySetName(Key1={Key1},Key2={Key2},Key3={Key3})": { },

What is actually happening.

Additional detail

*Optional, details of the root cause if known.

garegina avatar Nov 24 '21 18:11 garegina

Hi @garegina I have tested this and I'm unable to repro the issue. Could you please try with the latest lib. version and let us know if you are still experiencing this.

irvinesunday avatar Oct 03 '22 12:10 irvinesunday

Thanks for looking into this issue. I tried upgrading to the latest version.

And still the issue is reproducing for me.

garegina avatar Oct 04 '22 15:10 garegina

Sorry @garegina I understand your issue better now. Looking to resolve it.

irvinesunday avatar Oct 17 '22 12:10 irvinesunday

no worries @irvinesunday ! thanks for fixing the issue. is there an ETA when a new version will be released with this fixes?

garegina avatar Dec 12 '22 17:12 garegina

no worries @irvinesunday ! thanks for fixing the issue. is there an ETA when a new version will be released with this fixes?

The latest preview version has this fix: 1.2.0-preview8

irvinesunday avatar Dec 14 '22 09:12 irvinesunday