microsoft / microsoft/OpenAPI.NET.OData

Enum return value schema is wrong

未关闭
#674 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C#
星标
240
派生
70
平均合并
7 小时 59 分钟
30 天内合并 PR
13

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 OpenApiResponseGenerator.cs 开始,使用提供的 OData CSDL 重现函数响应。比较 collection 和 primitive 返回类型如何通过 enum path 进行包装,然后验证生成的 schema 使用了一个带有引用 RemoteAccessStatus 的 value 属性的 object。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, openapi
领域
api
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。