-
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-Angular2 produces invalid import for self-referencing model #6201
Comments
import { APISearchTerm } from './aPISearchTerm';
export interface APISearchTerm {
field?: string;
fieldValue?: string;
searchOperation?: APISearchTerm.SearchOperationEnum;
and?: Array<APISearchTerm>;
or?: Array<APISearchTerm>;
}
... @psamwel thanks for reporting the issue. What should be the correct output look like? |
@wing328 it should not have an import at the top because the interface is
in the same file
…On Fri, Jul 28, 2017, 10:11 AM wing328 ***@***.***> wrote:
import { APISearchTerm } from './aPISearchTerm';
export interface APISearchTerm {
field?: string;
fieldValue?: string;
searchOperation?: APISearchTerm.SearchOperationEnum;
and?: Array<APISearchTerm>;
or?: Array<APISearchTerm>;
}...
@psamwel <https://github.com/psamwel> thanks for reporting the issue.
What should be the correct output look like?
cc @Vrolijkx <https://github.com/vrolijkx> @taxpon
<https://github.com/taxpon> @sebastianhaas
<https://github.com/sebastianhaas> @kenisteward
<https://github.com/kenisteward> @TiFu <https://github.com/tifu>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6201 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMPLtcuatRCDg0YT_SvL-5kMbp6gPE3Aks5sSfougaJpZM4OlzXd>
.
|
@kenisteward looks like the issue we can loop through models via If anyone has better suggestions, please reply to let us know. |
That seems fine. I'm on vacation right now and don't have access to my
computer atm. But this should definitely be done for all clients.
I really wish I had time to recombine all the clients into 1 typescript 1
…On Fri, Jul 28, 2017, 10:17 AM wing328 ***@***.***> wrote:
@kenisteward <https://github.com/kenisteward> looks like the issue we can
loop through models via postProcessModels
<https://github.com/swagger-api/swagger-codegen/blob/78051257136d79f17c1dab7c814557f40e163c48/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen.java#L262>
and add vendor extensions (e.g. x-ts-angular2-self-ref) to avoid the import.
If anyone has better suggestions, please reply to let us know.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6201 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMPLtUhMXwYVHW2-rBCvs4_bA50XpENxks5sSfuNgaJpZM4OlzXd>
.
|
@kenisteward Enjoy your vacation 👍 |
Isn't this something that could happen in any language that uses imports? It feels weird to add Angular-specific logic for something that might happen in C# etc. as well :/ |
I don't think we have a generic handler for imports do we?
…On Mon, Jul 31, 2017, 8:20 AM Sebastian Haas ***@***.***> wrote:
Isn't this something that could happen in any language that uses imports?
It feels weird to add Angular-specific logic for something that might
happen in C# etc. as well :/
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6201 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMPLtTr22IcWZeqlLFSG7xoCvfLoCXOIks5sTdSdgaJpZM4OlzXd>
.
|
I'm getting the same issue in typescript-axios (I'm using https://github.com/sius/swagger-nodegen-cli v3.0.34) |
Description
typescript-angular2 client codegen for a model that references itself (e.g.):
resulting in:
which produces the following tsc error(s):
[12:04:12]Error at aPISearchTerm.ts:13:10: Individual declarations in merged declaration 'APISearchTerm' must be all exported or all local.
[12:04:12]Error at aPISearchTerm.ts:13:10: Import declaration conflicts with local declaration of 'APISearchTerm'
[12:04:12]Error at aPISearchTerm.ts:46:18: Individual declarations in merged declaration 'APISearchTerm' must be all exported or all local.
Swagger-codegen version
Verified in latest master & 2.3.0 locally.
2.3.0 branch
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i application.json -l typescript-angular2 -o $outputpath/sdk_angular2 -c $clientConfig
where $clientConfig:
{ "modelPropertyNaming": "original" }
Suggest a fix/enhancement
Exclude a classname from its own list of imports.
The text was updated successfully, but these errors were encountered: