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

[BUG][TYPESCRIPT-ANGULAR] client generated README with apiModulePrefix #7722

Closed
sorohan opened this issue Oct 15, 2020 · 3 comments · Fixed by #7725
Closed

[BUG][TYPESCRIPT-ANGULAR] client generated README with apiModulePrefix #7722

sorohan opened this issue Oct 15, 2020 · 3 comments · Fixed by #7725

Comments

@sorohan
Copy link
Contributor

sorohan commented Oct 15, 2020

Description

When specifying the apiModulePrefix the generated README still says to import ApiModule.

If you specify a prefix (eg PetStore) the generated README should say to import PetStoreApiModule.

openapi-generator version

4.3.0 (also checked on master)

OpenAPI declaration file content or url

The petstore YAML is sufficient to reproduce it.

Command line used for generation

You can generate using the samples, as the generated code contains the bug.

You can use the typescript-angular-with-prefixed-module-name-v8 sample:

sh bin/generate-samples.sh bin/configs/typescript-angular-with-prefixed-module-name-v8.yaml
Steps to reproduce
  1. clone the openapi-generator repo
  2. setup the repo (mvn clean package)
  3. generate the sample with prefixed module: sh bin/generate-samples.sh bin/configs/typescript-angular-with-prefixed-module-name-v8.yaml

Expected result:
Sample readme (samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-prefixed-module-name/README.md) should contain PetStoreApiModule.

Actual result:
Sample readme contains ApiModule.

See the general usage generated for the sample.

Suggest a fix/enhancement

I have a branch with the fix, and I can make a PR if you agree. See: https://github.com/OpenAPITools/openapi-generator/compare/master...sorohan:bugfix/typescript-angular-docs-with-module-prefix?expand=1

The thing I'm least sure about is updating the section on "Using multiple OpenAPI files / APIs / ApiModules". The advice given currently is to use:

import { ApiModule as OtherApiModule } from 'my-other-api-path';

But I think it would be better to just recommend people to use the apiModulePrefix option, as I assume that's what it's there for.

@sorohan sorohan changed the title [TYPESCRIPT][ANGULAR] client generated README with apiModulePrefix [BUG][TYPESCRIPT-ANGULAR] client generated README with apiModulePrefix Oct 15, 2020
@macjohnny
Copy link
Member

@sorohan a PR would be appreciated.
however, this line needs to be changed
https://github.com/sorohan/openapi-generator/blob/54d2f056f3ddd56847e969407f2d23c22dd19f75/modules/openapi-generator/src/main/resources/typescript-angular/README.mustache#L135

to
import { {{apiModuleClassName}} as OtherApiModule } from 'my-other-api-path';

@sorohan
Copy link
Contributor Author

sorohan commented Oct 15, 2020

No, that's not quite right, and that's why this section is a bit strange. Then you would have:

import { PetStoreModule } from 'my-api-path';
import { PetStoreModule } from 'my-other-api-path';

With the PR it will be

import { PetStoreModule } from 'my-api-path';
import { OtherApiModule } from 'my-other-api-path';

or

import { ApiModule } from 'my-api-path';
import { OtherApiModule } from 'my-other-api-path';

With the implication that you used Other as the prefix for the other module.

But I'm open for suggestions on how to make that more clear :)

Edit: I've opened the PR and tried to improve the wording, so we can discuss it there.

@macjohnny
Copy link
Member

@sorohan the line in question
https://github.com/OpenAPITools/openapi-generator/blame/master/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/with-npm/README.md#L136
serves as an example how to use / rename / alias api modules with the same name (e.g. if you use api packages published somewhere and you can't change/prefix the module name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants