We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug
Running this command:
spot generate --contract api.ts --language yaml --generator openapi3 --out build/
I get this error, once my model reaches a certain size (as it seems):
13 verbose stack Error: [email protected] generate: `spot generate --contract api.ts --language yaml --generator openapi3 --out build/` 13 verbose stack Exit status 1 13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:315:20) 13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:315:20) 13 verbose stack at maybeClose (internal/child_process.js:1048:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
To Reproduce Steps to reproduce the behavior:
Create the api.ts file:
api.ts
import { api, body, endpoint, request, response, String } from "@airtasker/spot"; @api({ name: "HAAPI" }) class Api { } @endpoint({ method: "POST", path: "/my-api" }) class MyEndpoint { @request request( @body body: Request ) { } @response({ status: 200 }) successfulResponse( @body body: MyResponse ) { } @response({ status: 400 }) problemResponse( @body body: ProblemResponse ) { } } interface Request { } interface ProblemResponse { type: string status: number title: string | null titleKey: string | null detail: string | null detailKey: string | null instance: string | null } type MyResponse = Step // All MyResponse types extend from BaseResponse interface BaseResponse { // TODO add more types type: "step" links: Link[] messages: Message[] } interface Step extends BaseResponse { type: "step" actions: Action[] } interface Link { href: string; rel: "self" | "continue"; message: string | null; messageKey: string | null; } interface Message { text: string | null key: string | null classList: string[] } type Action = FormAction// | SelectorAction interface FormAction { template: "form" // notice that kind can be any string... here we just enumerate the most common kinds kind: "form" | "redirect" | string model: FormModel } // interface SelectorAction { // template: "selector" // // notice that kind can be any string... here we just enumerate the most common kinds // kind: "selector-authenticator" | string // title: string | null, // titleKey: string | null, // model: SelectorModel // } interface FormModel { href: string method: "GET" | "POST" | "PATCH" | "DELETE" | "PUT" mediaType: string title: string | null titleKey: string | null actionTitle: string | null actionTitleKey: string | null fields: FormField[] } // interface SelectorModel { // title: string | null // titleKey: string | null // options: Action[] // } interface FormField { name: string type: "input" | "hidden" | "text" | "email" | "context" label: string | null labelKey: string | null value: string | null }
Run spot generate --contract api.ts --language yaml --generator openapi3 --out build/.
It works fine... un-comment the few commented-out types in the example above and try again.
It will fail with the error mentioned above.
Expected behavior
It should not fail.
The text was updated successfully, but these errors were encountered:
Oh... I've just actually noticed that this seems to be related to the fact that the the commented-out type, SelectorModel, introduces type recursion!
SelectorModel
Is there a workaround for cases like this?
Sorry, something went wrong.
I assume this error is caused by the lack of support for recursive types mentioned at #1081?
Hi @renatoathaydes, sorry for the delayed response. Yup its exactly what you assumed, Spot currently doesn't expect recursive types.
Hello, is there any workaround for this issue while we wait for recursive support?
No branches or pull requests
Describe the bug
Running this command:
I get this error, once my model reaches a certain size (as it seems):
To Reproduce
Steps to reproduce the behavior:
Create the
api.ts
file:Run
spot generate --contract api.ts --language yaml --generator openapi3 --out build/
.It works fine... un-comment the few commented-out types in the example above and try again.
It will fail with the error mentioned above.
Expected behavior
It should not fail.
The text was updated successfully, but these errors were encountered: