Closed lsarni closed 8 years ago
@daisymoon thanks for reporting the issue. I think it's due to the following:
May I know if you've cycle to look into the issue and ideally submit a PR with the fix?
I decided to try all of the languages with this yaml and got the following results:
Those where the results, the ones that don´t have a comment generated the model for ObjectForTest but not for List or Map. Here is the code that each one generated
@wing328 do you still think the problem might be related to AbstractCSharpCodegen?
I´ve been looking at the code and the problem seems to be here Running the yaml I added this lines to see if it was here where the models where getting lost:
if (config.importMapping().containsKey(name)) {
LOGGER.warn(name);
continue;
}
LOGGER.info(name);
And got this as a result:
[main] WARN io.swagger.codegen.DefaultGenerator - Map
[main] WARN io.swagger.codegen.DefaultGenerator - List
[main] INFO io.swagger.codegen.DefaultGenerator - ObjectForTest
So that´s where the problem seems to be.
The values for importMapping are stated here in DefaultCodegen.
And I checked why this isn´t a problem in some of the languages. They all seem to be either: removing List and Map from the typeMapping values, creating a new typeMapping object or clearing the typeMapping object.
I think there is more than one way in which this could be solved:
Any of this options will have effects on how the code is generated that might not be what you are looking for so i´m not sure which one would be the best fix.
@daisymoon thanks for the detailed findings. I do not have an answer on which one is the best way to fix the issue.
I'll take a deeper look after the 2.2.0 stable release.
@wing328 @daisymoon I think we can re-initialize the importMappings
hash for AbstractCSharpCodegen
. Those java-y mappings aren't relevant for .NET types.
The swagger-codegen-cli
module allows for an import-mappings switch, which is applied to the CodegenConfigurator instance. The CodedgenConfigurator
instantiates the relevant C# generator based on other parameters passed to the tool, and uses the DefaultGenerator
type for generation of all generators (this is where the import mappings are consumed). We don't really do imports in the C# code the way Java does.
So, my proposal for this issue is to clear the importMappings
for C# generators in AbstractCSharpCodegen
then open another issue to add support for the import-mappings
switch to C# generators (at least csharp, nancyfx, and aspnet5)
@jimschubert thanks for the suggestion.
@daisymoon I'll take a look tomorrow (Sunday) or Monday when I've time. Hopefully I'll have a PR to fix the issue.
@daisymoon I've filed #3454 to fix the issue using Jim's proposal.
For Java-related generators, we'll file another PR to address the issue later.
Description
I have this json that defines a model called "Map". I noticed that both in java and csharp this gets ignored when generating the code, I'm building a generator for a personalized language and it also gets ignored. What I did was changing the name to "Mapa", and the problem is solved. But if I name it "List" I get the same problem, so it seems to be related to names that exist as types (like tony tam guessed here)
Swagger declaration file content or url