microsoft / microsoft/OpenAPI.NET.OData

Refactor the whole project

Open
#69 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:needs-discussion type:feature
Dominant language
C#
Stars
240
Forks
70
Avg merge
7h 59m
Merged PRs (30d)
13

Description

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.

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.

Research direction

No source files or tests are named. Start by tracing the OData-to-OpenAPI conversion flow and reviewing the proposed IOpenApiODataConverter, IODataPathProvider, path and operation handlers, and UseOpenApiOData registration example. Done requires an agreed service boundary and dependency-injection design that supports customized conversion.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend-api-design
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.