Open nize opened 6 years ago
@nize thanks for reporting. does the error also occur in an angular 4 project?
@macjohnny: No, for angular 4 it works.
npm uninstall -g @angular/cli
npm install -g @angular/cli@">=1.4.0 <1.5.0"
ng new petstore-app-angular4
cd petstore-app-angular4/
npm i petstore-angular4-api
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { ApiModule } from 'petstore-angular4-api';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
ApiModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import { Component } from '@angular/core';
import { PetService, Pet,StoreService } from 'petstore-angular4-api';
import { Observable } from 'rxjs/Observable';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
constructor(private petService: PetService) {
var response = petService.findPetsByStatus(["available"]);
response.subscribe(val => this.title = val.length.toFixed());
}
}
@nize are you symlinking the generated package or copying / downloading it from a repository?
if you are symlinking it: there is a bug in @angular/cli>1.4.7
, see https://github.com/angular/angular-cli/issues/8284
I recently ran into this problem using code-gen 2.4.0.
I got around the issue by publishing the compiled output. When publishing specify the "/dist" folder
npm install
npm build
npm publish dist
I was tipped onto this by looking at the documentation in the PetStore sample.
It does appear the output of README.md differs based on some configuration.
I am trying to generate the api and publishing it to an private registry. and i am getting this error with angular 9 AOT compile/debug
The issue was that ng-packagr requires cli execution
and i had in my .npmrc file: ignore-scripts=true
enabled.
The npm run build
didn't throw errors and any output
The 'npm publish dist' tried to publish to 'https://myrepo.demo.test/repository/dist'
but with ''npm publish my-module' it published to 'https://myrepo.demo.test/repository/my-module'
enabling ignore-scripts
resolved the issue.
Description
When trying to consume a module generated by the Swagger-codegen typescript-angular for version 4.3 in a angular 5 project
ng serve
crashes and says:Swagger-codegen version
2.3.1
Swagger declaration file content or url
http://petstore.swagger.io/v2/swagger.json
Command line used for generation
java -jar .\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l typescript-angular -o C:\angular\petstore-angular4-api
Also tried:
java -jar .\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l typescript-angular -o C:\angular\petstore-angular527-api -c swagger-codegen-config-angular527.json
where the file swagger-codegen-config-angular527.json contained:
{"ngVersion":"5.2.7"}
Steps to reproduce
java -jar .\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l typescript-angular -o C:\angular\petstore-angular4-api
cd C:\angular\petstore-angular4-api
npm login
npm publish
cd C:\angular\petstore-app
npm install petstore-angular4-api
code .
import { ApiModule } from 'petstore-angular4-api';
ApiModule
import { PetService} from 'petstore-angular4-api'
constructor(private petService: PetService) {}
ng serve
Related issues/PRs
None
Suggest a fix/enhancement
Add angular 5 support to Swagger-codegen ? Add documentation on which parameters are allowed for the parameter
ngVersion
?