diff --git a/node-runtime/src/swagger.ts b/node-runtime/src/swagger.ts index 482133a83..0234ff8a3 100644 --- a/node-runtime/src/swagger.ts +++ b/node-runtime/src/swagger.ts @@ -2,6 +2,7 @@ import type { Type } from "@sdkgen/parser"; import { ArrayType, Base64PrimitiveType, + BigIntPrimitiveType, BoolPrimitiveType, BytesPrimitiveType, CnpjPrimitiveType, @@ -128,6 +129,10 @@ function typeToSchema(definitions: Record, type: return { type: "string", }; + } else if (type instanceof BigIntPrimitiveType) { + return { + type: "string", + }; } else if (type instanceof OptionalType) { return { oneOf: [typeToSchema(definitions, type.base), { type: "null" }], @@ -214,7 +219,7 @@ export function setupSwagger(server: SdkgenHttpServer { + server.addHttpHandler("GET", /^\/swagger.*/u, (req, res) => { if (!server.introspection) { res.statusCode = 404; res.end(); diff --git a/playground/src/stores/requests.ts b/playground/src/stores/requests.ts index d1a12c55a..8fc54bcaa 100644 --- a/playground/src/stores/requests.ts +++ b/playground/src/stores/requests.ts @@ -8,7 +8,21 @@ import { v4 as uuidV4 } from "uuid"; import type { RootStore } from "."; export const simpleStringTypes = ["string", "cep", "cnpj", "cpf", "email", "html", "phone", "url", "xml"]; -export const simpleTypes = ["json", "bool", "hex", "uuid", "base64", "int", "uint", "float", "money", "void", "latlng", ...simpleStringTypes]; +export const simpleTypes = [ + "json", + "bool", + "hex", + "uuid", + "base64", + "bigint", + "int", + "uint", + "float", + "money", + "void", + "latlng", + ...simpleStringTypes, +]; export class RequestsStore { public rootStore: RootStore; @@ -51,6 +65,7 @@ export class RequestsStore { email: "hello@example.com", float: 12.3, hex: "deadbeef", + bigint: "123456789", int: 123, json: { anything: [1, 2, 3] }, latlng: undefined, @@ -110,7 +125,7 @@ export class RequestsStore { return this.encodeTransform(typeTable, resolved); } - throw new Error(`Unknown type '${type}'`); + return null; } public getAnotations = (AST: AstJson, functionName: string): ModelAnotations => {