microsoft / microsoft/OpenAPI.NET.OData

Refactor the whole project

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

还没有人认领这个 Issue。

status:needs-discussion type:feature
主要语言
C#
星标
240
派生
70
平均合并
7 小时 59 分钟
30 天内合并 PR
13

描述

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

Recently, I got a lot of requirements, for example

  1. I don't want to expand on certain element
  2. I don't need this operation
  3. I need this ...
  4. etc..

Yes, we can meet all of these by modifying the codes, by adding settings, etc.
However, i'd think maybe it's time to refactor it in the next major release.

Design

I'd like to use the Dependency Injection to allow customer to customize the converting process.

We need figure out the working flow from OData to OpenAPI. The process steps are certain, at each step, we can create a service to work on it.

Services

We need figure out the services used during converting.
for example:

  1. we should have a OData path provider service
  2. we should have a OpenApi path generator service
  3. We should have a convert engine

Extension methods

I think we need

public static IServiceCollection UseOpenApiOData(IServiceCollection services)
{
        services.AddSingleton<IOpenApiODataConverter>(); // converter or generator
        services.AddSingleton<IODataPathProvider>();
        services.AddSingleton<IODataOpenApiPathHandler>();
        services.AddSingleton<IODataOpenApiOperationHandler>();
.....
        service.AddSingleton<ODataOpenApiOptions>();
        return services;
}

Usage

  1. you can create the OpenApiODataConverter instance (normal way)
  2. you can retrieve it from service provider.
IServiceCollection services= new ServiceCollection();
services.UserOpenApiOData();
IServiceProvider sp = services.CreateServiceProvider();
IOpenApiODataConverter converter = sp.GetService<IOpenApiODataConverter>();
...

Advantage

  1. It can be used in the ASP.NET Core pipeline, for example we can create a middleware to generate the OpenAPI description for a OData service.

  2. It can support to customize the converting. For example, we can replace a certain service using customized service.

贡献指南

打开贡献指南

从这里开始

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

调研方向

未指定源文件或测试。首先跟踪 OData-to-OpenAPI 转换流程,并审查提议的 IOpenApiODataConverter、IODataPathProvider、path 和 operation 处理程序,以及 UseOpenApiOData 注册示例。完成条件是确定一个达成共识的服务边界和支持自定义转换的 dependency injection 设计。

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

评估

技术栈
csharp
领域
backend-api-design
Issue 类型
重构
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
20/100

把新 issue 发到你的邮箱

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