OpenAPITools / OpenAPITools/openapi-generator

[BUG][aspnetcore] Resolve Conflict between Program.cs and launchProfile

Open
#12,216 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

There are multiple ways to specify the hosting Url for an aspnetcore application:

  1. Specifying it via Environment Variables
  2. Specifying it during development via launchProfiles
  3. Specifying it in code (Overwriting any other settings)

Currently the generator uses option 3:
https://github.com/OpenAPITools/openapi-generator/blob/5b6b4c9d4829b57716741dc35b3f1033e5483784/modules/openapi-generator/src/main/resources/aspnetcore/3.0/Program.mustache#L30

Which in my opinion is not alright, because as stated in the README.md:
https://github.com/OpenAPITools/openapi-generator/blob/5b6b4c9d4829b57716741dc35b3f1033e5483784/modules/openapi-generator/src/main/resources/aspnetcore/3.0/build.bat.mustache#L8

We should be able to use the launchProfiles. But as it is coded into the program it will always use serverPort.

Suggest a fix

Remove the line and maybe add a documentation link on how to setup the right port.

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 with modules/openapi-generator/src/main/resources/aspnetcore/3.0/Program.mustache, especially the hosting URL line linked in the issue, and compare it with Properties/launchSettings.json and the README reference in build.bat.mustache. Done means launchProfiles can determine the development port instead of always being overridden by serverPort.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.