-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[typescript-angular] upgrade to support angular v6 (breaking changes due to rxjs v6) #8179
Comments
The issue is always present when i use typescript-angular api : https://generator.swagger.io/api/gen/clients/typescript-angular |
@pegaltier this is because generator.swagger.io uses version 2.3.1, and the fix is in the current master branch. however, there is a current release of OpenAPI Generator that fully supports angular 6 and rxjs v6. see https://github.com/openapitools/openapi-generator |
@pegaltier if you need to use swagger-generator, you can use the following 2 mustache files from swagger master, if you just override the default mustache files with these 2: For example in your pom: <groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<executions>
<execution>
<id>swagger-wallet-api-codegen</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.build.directory}/swagger/wallet/meta/swagger.json</inputSpec>
<language>typescript-angular</language>
<output>src/generated/wallet-api</output>
<templateDirectory>../_mustache</templateDirectory>
<configOptions>
<ngVersion>6.0</ngVersion>
</configOptions>
</configuration>
</execution> |
SNAPSHOT builds of master do not work for me due to at least one open issue and unmerged PR. So, is the answer "use openapi-generator instead"? |
Bad Newsopenapi-generator has issues with my JSON Schema files (you'd think they'd honor the spec)... no go. Good NewsFor released version 2.3.1 of swagger-codgen, doing #BeerMe |
@fizxmike Could you explain a little bit more on how you got swagger-codegen working so it can be used with angular 6? |
The main issue is that with the current "release" of swagger-codegen (v2.3.1), the typescript-angular client for version 6 uses the wrong version of rxjs, so build of client will fail. The "workaround" is to install the right version of rxjs (version 6) AND rxjs-compat (version 6). So do this in client folder (after codegen): npm install
npm install rxjs@6 rxjs-compat@6
npm build Of course, when you codegen, use the {
"npmName":"my-swagger-package",
"npmVersion":"0.0.1",
"ngVersion":"6"
} Summaryjava -jar swagger-codegen-cli-2.3.1.jar -l typescript-angular -c config.json -i swagger.yml -o angular6clinet
cd angular6client
npm install
npm install rxjs@6 rxjs-compat@6
npm build To make the fix "stick" add this line to your angular6clinet/.swagger-codegen-ignore file: # keep package.json frozen since it has fix (https://github.com/swagger-api/swagger-codegen/issues/8179#issuecomment-401208765)
package.json This way you can update your swagger.yml and rebuild the client without clobbering the fix. |
Description
Angular v6 just released which has a dependency on rxjs v6. Specifically, imports for Observables have changed: https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md
It looks like we'll need to update:
import { Observable } from 'rxjs/Observable';
to:
import { Observable } from 'rxjs'
Suggest a fix/enhancement
I propose we add an additional property
useRxjsVersion6Imports
that istrue
ifngVersion
is greater than 6.0.0 to determine which import to display. I'd also be willing to take a shot at this if approved.The text was updated successfully, but these errors were encountered: