swagger-api / swagger-api/swagger-codegen

[angular2-typescript] Using xAny throws an Error: Cannot find name 'xAny'

Open
#4,710 0 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

Swagger-codegen for the angular2-typescript client uses xAnywhich cannot be found and throws an error:

ERROR in [at-loader] client/app/api/model/role.ts:23:15 
    Cannot find name 'xAny'.

ERROR in [at-loader] client/app/api/model/role.ts:25:16 
    Cannot find name 'xAny'.

my role.ts:

import { XAny } from './xAny';

export interface Role {
    id?: number;

    name: string;

    description?: string;

    created?: xAny;

    modified?: xAny;
}
Swagger-codegen version

2.3.0 - https://github.com/swagger-api/swagger-codegen/tree/2.3.0

Swagger declaration file content or url

swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar

Command line used for generation

shell script used for api-generation autogenerate-api-client.sh:

java -jar ../swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i http://localhost:3000/explorer/swagger.json -l typescript-angular2 -o client/app/api
Steps to reproduce

node version: v6.3.0

start backend using node,

generate client api:
sh autogenerate-api-client.sh

npm version: 3.10.8

started in terminal:
npm test

--> Error

Related issues
Suggest a Fix

maybe use type any instead of xAny

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 client/app/api/model/role.ts and the typescript-angular2 generator invoked by autogenerate-api-client.sh. Reproduce the generation with the listed Swagger-codegen command, then inspect the generator path responsible for these model types. Done means the generated Role model uses a defined TypeScript type and npm test completes without the Cannot find name error.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.