OpenAPITools / OpenAPITools/openapi-generator
[BUG] [aspnetcore] aspnetCoreVersion 6.0 not compatible with 3.0 mustache templates
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When using aspnetCoreVersion=6.0 parameter the generated Dockerfile is corrupt.
openapi-generator version
openapi-generator-cli-6.2.0.jar
https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.2.0/openapi-generator-cli-6.2.0.jar
OpenAPI declaration file content or url
Command line used for generation
java -jar openapi-generator-cli-6.2.0.jar generate -g aspnetcore --additional-properties aspnetCoreVersion=6.0 --additional-properties classModifier=abstract --additional-properties operationModifier=abstract --additional-properties packageName=Pet --additional-properties packageTitle=Pet.Api -i https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml --skip-validate-spec
Steps to reproduce
java -jar openapi-generator-cli-6.2.0.jar generate -g aspnetcore --additional-properties aspnetCoreVersion=6.0 --additional-properties classModifier=abstract --additional-properties operationModifier=abstract --additional-properties packageName=Pet --additional-properties packageTitle=Pet.Api -i https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml --skip-validate-spec
This will generate a the following Dockerfile:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
# Container we use for final publish
FROM mcr.microsoft.com/dotnet/core/aspnet:6.0-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
# Build container
FROM mcr.microsoft.com/dotnet/core/sdk:6.0-buster AS build
# Copy the code into the container
WORKDIR /src
COPY ["src/Pet/Pet.csproj", "Pet/"]
# NuGet restore
RUN dotnet restore "Pet/Pet.csproj"
COPY ["src/Pet/", "Pet/"]
# Build the API
WORKDIR "Pet"
RUN dotnet build "Pet.csproj" -c Release -o /app/build
# Publish it
FROM build AS publish
RUN dotnet publish "Pet.csproj" -c Release -o /app/publish
# Make the final image for publishing
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Pet.dll"]
The referenced base images (mcr.microsoft.com/dotnet/core/aspnet:6.0-buster-slim + mcr.microsoft.com/dotnet/core/sdk:6.0-buster) in the Dockerfile do not exist!
$ cd src/Pet
$ docker build -t petstore:1.0.17 .
[+] Building 0.6s (4/4) FINISHED
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 873B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> ERROR [internal] load metadata for mcr.microsoft.com/dotnet/core/sdk:6.0-buster 0.4s
=> CANCELED [internal] load metadata for mcr.microsoft.com/dotnet/core/aspnet:6.0-buster-slim 0.4s
------
> [internal] load metadata for mcr.microsoft.com/dotnet/core/sdk:6.0-buster:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: mcr.microsoft.com/dotnet/core/sdk:6.0-buster: not found
Related issues/PRs
Suggest a fix/enhancement
see here
This has to be fixed. "6.0" must not use 3.0 templates
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AspNetCoreServerCodegen.java around line 678, then reproduce the generation command with aspnetCoreVersion=6.0 and the Petstore specification. Verify that the generated Dockerfile uses valid .NET 6 base images rather than the 3.0 template values, and confirm the generated project can build with Docker.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- devops, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100