Skip to content

Commit

Permalink
Release/1.6.2 (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbguilherme committed Oct 27, 2021
1 parent 5cbc70a commit d5cedae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
7 changes: 6 additions & 1 deletion node-runtime/src/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Type } from "@sdkgen/parser";
import {
ArrayType,
Base64PrimitiveType,
BigIntPrimitiveType,
BoolPrimitiveType,
BytesPrimitiveType,
CnpjPrimitiveType,
Expand Down Expand Up @@ -128,6 +129,10 @@ function typeToSchema(definitions: Record<string, JSONSchema | undefined>, 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" }],
Expand Down Expand Up @@ -214,7 +219,7 @@ export function setupSwagger<ExtraContextT>(server: SdkgenHttpServer<ExtraContex
res.end();
});

server.addHttpHandler("GET", /^\/swagger/u, (req, res) => {
server.addHttpHandler("GET", /^\/swagger.*/u, (req, res) => {
if (!server.introspection) {
res.statusCode = 404;
res.end();
Expand Down
19 changes: 17 additions & 2 deletions playground/src/stores/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 => {
Expand Down

0 comments on commit d5cedae

Please sign in to comment.