OpenAPITools / OpenAPITools/openapi-generator

[aspnetcore] Minor cleanups to library-based output

Open
#2,285 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Server: C-Sharp
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Some minor issues found during verification of #2282, but can be fixed after merge of that PR:

  • generating as buildTarget=library omits Dockerfile, but does not remove docker build steps from README.md
  • When specifying classModifier=abstract and method body is omitted, semicolon is below the abstract method signature, and should be on the same line
  • I think this was mentioned in the original PR: wwwroot shouldn't be generated for library options (or should it? I don't think it makes sense, and I don't know if aspnet allows pulling wwwroot from a dependency).

Additional TODOs for the library-based generated output:

  • make class and operation modifiers enums on CLI input

  • validate combinations of modifiers (class + operation), and disallow any which shouldn't be allowed by the language (such as disallowing partial methods, which can't be virtual and can't be applied to non-void methods-- we return IActionResult)

  • README should explain how to use the generated code, as it may not be immediately obvious to some users. Example of ConfigureServices in Startup.cs:

             services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
                 .AddApplicationPart(typeof(PetApiController).Assembly)
                 .AddControllersAsServices();
    

    Note: users installing new dotnet SDK(at least on Mac with Rider) can only generate .NETCore 2.2 and need to upgrade the project for the above to work. The above should work for .NETCore 2.1 by removing .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)

openapi-generator version

n/a

OpenAPI declaration file content or url

n/a

Command line used for generation

n/a

Steps to reproduce
Related issues/PRs

#2282

Suggest a fix/enhancement

n/a

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

Start by reviewing the generated library output and the related PR #2282, then inspect README.md and the CLI options for classModifier and operation modifiers. Done means library generation no longer includes inappropriate Dockerfile, Docker build steps, or wwwroot output, abstract method formatting is corrected, modifier combinations are validated, and README.md documents the Startup.cs integration.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, cli, documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.