Enum return value schema is wrong

Open
#674 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
csharp, openapi
Domain
api

Research direction

Start in OpenApiResponseGenerator.cs and reproduce the function response using the provided OData CSDL. Compare how collection and primitive return types are wrapped with the enum path, then verify that the generated schema uses an object with a value property referencing RemoteAccessStatus.

Written by the indexing model from the issue text.

Description

If a function returns Enum resulting schema is not wrapped but instead represented as enum itself.

Assemblies affected

Microsoft.OpenApi.OData 1.7.4

Steps to reproduce

I have a function that returns enum. It goes like this:

<Function Name="GetRemoteAccessStatus" IsBound="true">
      <ReturnType Type="RemoteAccessStatus" Nullable="false"/>
</Function>

<EnumType Name="RemoteAccessStatus">
      <Member Name="None" Value="0"/>
      <Member Name="Requested" Value="1"/>
      <Member Name="Active" Value="2"/>
</EnumType>
Expected result

In the resulting schema I want to see something like this:

      schema:
        type: object
        properties:
          value:
              anyOf:
                  - $ref: '#/components/schemas/RemoteAccessStatus'
Actual result

Actually I get (skipped value):

      schema:
        $ref: '#/components/schemas/Pbx.RemoteAccessStatus'
Additional information

I thinks the issue is in OpenApiResponseGenerator.cs where for collection and primitive types it wraps the responses but not for Enum

Dominant language
C#
Stars
240
Forks
70
Avg merge
7h 59m
Merged PRs (30d)
13

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/OpenAPI.NET.OData

All issues in microsoft/OpenAPI.NET.OData

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.