Generator tries to insert such import:
import { MapSwagger } from './modelMap';
when suffix is provided (e.g. Swagger)
and model contains map inside (same for services which take map as parameter)
modelMap?: { [key: string]: any; };
3.2.2
3.2.3
{
"supportES6": true,
"providedInRoot": "true",
"modelSuffix": "Swagger",
"ngVersion": "6.1.4"
}
java -jar openapi-generator-cli.jar generate -g typescript-angular -c openapi-config.json -i $1 -o $2
where $1 and $2 are input and output.
"Model": {
"type": "object",
"properties": {
"modelMap": {
"type": "object",
"additionalProperties": {
"type": "object"
}
},
}
},
Exclude native js classes from imports before suffix applied.
@Ilya1vanov could you please explain more in detail which part of the output is not correct?
Maybe https://github.com/OpenAPITools/openapi-generator/pull/767 by @softdays resolves your issue?
@macjohnny thank you for your reply. #767 doesn't fix this issue.
import { MapSwagger } from './modelMap';
The problem is that there is no MapSwagger class in my json documentation (./modelMap file doesn't exist as well). I suppose, that it's a native js Map class, but name was changed with suffix and then it wasn't excluded from imports.
@Ilya1vanov ah, ok, I see, you are right.
Would you be up to giving it a try and fix the issue?
I think the starting point would be somewhere here:
@macjohnny I don't think I'm good at Java. I want to ask you to fix it, if you don't mind.
On the face of it, the issue is in statement execution order. Map, Set, etc. (languageSpecificPrimitives array) have to be excluded from tsImports (for model) and imports (for api.service) before suffix is applied. But I'm not sure it is as simple as at first glance. You know code better.
Anyway, thank you a lot. That would be great if you fix it!
@Ilya1vanov i filed PR #973 which fixes this issue.
@macjohnny thank you. You are doing a great job!
Will #973 be added to 3.3.0 release in September? And when 3.3.0 is scheduled?
@Ilya1vanov it looks like this will be added to the 3.3.0 release, due in September 2018 (see https://github.com/OpenAPITools/openapi-generator/issues/956)
Most helpful comment
@Ilya1vanov i filed PR #973 which fixes this issue.