swagger-api / swagger-api/swagger-codegen

index.ts is missing from the TypeScript compilation

Open
#7,768 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

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:

ERROR in ./node_modules/petstore-angular4-api/index.ts
Module build failed: Error: C:\angular\petstore-app\node_modules\petstore-angular4-api\index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).
    at AngularCompilerPlugin.getCompiledFile (C:\angular\petstore-app\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:674:23)
    at plugin.done.then (C:\angular\nils-petstore-app\node_modules\@ngtools\webpack\src\loader.js:467:39)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

webpack: Failed to compile.
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
  1. java -jar .\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l typescript-angular -o C:\angular\petstore-angular4-api
  2. cd C:\angular\petstore-angular4-api
  3. npm login
  4. npm publish
  5. cd C:\angular\petstore-app
  6. npm install petstore-angular4-api
  7. code .
  8. Added to app.module.ts: import { ApiModule } from 'petstore-angular4-api';
  9. Added to app.module.ts imports: ApiModule
  10. Added to app.compontent.ts: import { PetService} from 'petstore-angular4-api'
  11. Added to app.compontent.ts: constructor(private petService: PetService) {}
  12. 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 ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated package's index.ts and the consuming app's app.module.ts and app.component.ts, then reproduce the failure with ng serve using the listed generation commands. Determine whether the generated package can be compiled and published for Angular 5, and document the supported ngVersion values if that is the selected scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.