openapi-generator
openapi-generator copied to clipboard
[BUG] [csharp-functions] custom packageName value is not used for usings in DefaultApi class
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [ ] Have you validated the input using an OpenAPI validator (example)?
- [ ] Have you tested with the latest master to confirm the issue still exists?
- [x] Have you searched for related issues/PRs?
- [x] What's the actual output vs expected output?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Generator used: csharp-functions After generation and without 'human' changes, solution is not building.
1st issue:
After setting up custom packageName, DefaultApi file generated with it has wrong using.
It has default using Org.OpenAPITools.Models;, but should be using FirstName.RestApiServer.Models; in this case.
2nd issue is that it does not put using System.Collections.Generic;.
After manually fixing these 2 usings, solution is compiling with success.
openapi-generator version
Using latest docker image. First time using that generator, so do not know if it is regression.
OpenAPI declaration file content or url
openapi: '3.0.3'
info:
title: TestApi
description: xyz
version: 1.0.0
servers:
- url: 'https://xyz/api'
description: Production server
- url: 'localhost/api'
description: TEST
paths:
/test:
get:
summary: "Test if server is working"
description: "Test if server is working"
responses:
'200':
description: OK
content:
application/json:
schema:
type: string
/matches:
get:
summary: "Get matches for user"
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
type: object
properties:
prop1:
type: integer
prop2:
type: string
Generation Details
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate `
-i /local/spec.yml `
-g csharp-functions `
-o /local/out/server `
--additional-properties=packageName=FirstName.RestApiServer
Steps to reproduce
- Run generation command
- Open solution in VS 2022.
- Try to compile it
Results from VS:
Build started at 11:03...
1>------ Build started: Project: FirstName.RestApiServer, Configuration: Debug Any CPU ------
1>D:\repos\GeneratorBug\out\server\src\FirstName.RestApiServer\Functions\DefaultApi.cs(14,7,14,10): error CS0246: The type or namespace name 'Org' could not be found (are you missing a using directive or an assembly reference?)
1>D:\repos\GeneratorBug\out\server\src\FirstName.RestApiServer\Functions\DefaultApi.cs(21,40,21,72): error CS0246: The type or namespace name 'List<>' could not be found (are you missing a using directive or an assembly reference?)
1>D:\repos\GeneratorBug\out\server\src\FirstName.RestApiServer\Functions\DefaultApi.cs(21,45,21,71): error CS0246: The type or namespace name 'MatchesGet200ResponseInner' could not be found (are you missing a using directive or an assembly reference?)
1>Done building project "FirstName.RestApiServer.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 11:03 and took 01,268 seconds ==========
Related issues/PRs
Do not know
Suggest a fix
Something with using list.