Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[angular-typescript] Bug generating model with suffix #957

Closed
Ilya1vanov opened this issue Sep 3, 2018 · 7 comments · Fixed by #973
Closed

[angular-typescript] Bug generating model with suffix #957

Ilya1vanov opened this issue Sep 3, 2018 · 7 comments · Fixed by #973

Comments

@Ilya1vanov
Copy link

Description

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; };
openapi-generator version

3.2.2
3.2.3

OpenAPI declaration file content or url
{
  "supportES6": true,
  "providedInRoot": "true",
  "modelSuffix": "Swagger",
  "ngVersion": "6.1.4"
}
Command line used for generation
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.

Steps to reproduce
  1. Generate model from json like this:
    "Model": {
      "type": "object",
      "properties": {
        "modelMap": {
          "type": "object",
          "additionalProperties": {
            "type": "object"
          }
        },
      }
    },
  1. Pass any suffix to generator's options
Related issues/PRs
Suggest a fix/enhancement

Exclude native js classes from imports before suffix applied.

@macjohnny
Copy link
Member

@Ilya1vanov could you please explain more in detail which part of the output is not correct?
Maybe #767 by @softdays resolves your issue?

@Ilya1vanov
Copy link
Author

Ilya1vanov commented Sep 4, 2018

@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
Copy link
Author

@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!

@macjohnny
Copy link
Member

@Ilya1vanov i filed PR #973 which fixes this issue.

@Ilya1vanov
Copy link
Author

@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?

@macjohnny
Copy link
Member

@Ilya1vanov it looks like this will be added to the 3.3.0 release, due in September 2018 (see #956)

wing328 pushed a commit that referenced this issue Sep 6, 2018
* #957: add missing type mapping

* #957: generate samples
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this issue Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants