-
-
Notifications
You must be signed in to change notification settings - Fork 131
Add imports to typescript generator #116
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
Conversation
ping @alanpoulain or @dunglas (should I ping someone else as well?) |
Travis was failing, I forgot to run |
… reference other fields Add test to test interface without references
I've noticed a thing. At the moment the handlebars template for the typescript interface has the {{#each imports}}
import { {{type}} } from "{{file}}";
{{/each}}
{{#if imports.length}}
{{/if}}
export interface {{{name}}} {
'@id'?: string;
id: string;
{{#each fields}}
{{#if readonly}} readonly{{/if}} {{{name}}}{{#if notrequired}}?{{/if}}: {{{type}}};
{{/each}}
} I'd make both non-required, otherwise you might have issues when using that interface for POST (collection add) operations, where the ID might be unspecified (or would you have to set it as What do you think? |
@luca-nardelli I agree with you. Can you open a new PR please? |
Thanks @luca-nardelli |
You're welcome! I'll open the other PR asap |
Done! #123 |
I've noticed that the generated interfaces for typescript are missing the
import { ResourceName } from "./resourcefile";
statements, making them less useful when used in a Typescript application (imports would need to be manually added everytime).This PR fixes this and also adds a test to the typescript generator, testing for both interfaces with references to other interfaces and interfaces without references.