简体   繁体   中英

Ambiguous reference error in OpenApi-generated c# code

I'm using OpenAPI Generator to generate client libraries for my c# API. I am having issues generating ac# client, because one of my models is called Environment. The generated service code to manipulate this model causes the build of the project to fail because it is an ambiguous reference between it's own model and .Net's System.Environment.

The exact error I'm seeing is Api/EnvironmentApi.cs(87,42): error CS0104: 'Environment' is an ambiguous reference between 'MyProject.Model.Environment' and 'System.Environment'

Is there some way to tell openapi-generator to fully-qualify the class names in the generated code so that it won't clash? ie so it generates something like

DoSomething<MyProject.Model.Environment>(...) instead of DoSomething<Environment>(...)

It's been a while since the request was opened for swagger: https://github.com/swagger-api/swagger-codegen/issues/2630

Bear in mind that I'm referring swagger as it is the project that was forked to make openapi generator. https://github.com/OpenAPITools/openapi-generator/blob/master/docs/migration-from-swagger-codegen.md#new-fully-qualified-name-for-the-classes

OpenAPI Generator is a fork of swagger-codegen between version 2.3.1 and 2.4.0

So the answer is most probably no.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM