Skip to content
Snippets Groups Projects
Commit f542d5c2 authored by Paolo.Brasolin's avatar Paolo.Brasolin
Browse files

feat: #be define Nullable for OpenAPI

parent 57144313
No related branches found
No related tags found
No related merge requests found
import { FastifyPluginCallback } from "fastify";
import { Static, Type } from "@sinclair/typebox";
import { Static, Type, TSchema, TUnion, TNull } from "@sinclair/typebox";
function Nullable<T extends TSchema>(schema: T): TUnion<[T, TNull]> {
return { ...schema, nullable: true } as any;
}
import { connection } from "./db";
// NOTE: refer to https://cloud.google.com/apis/design/
// NOTE: see https://www.npmjs.com/package/fastify-plugin for TS plugin definition
const IdInParamsSchema = Type.Object({
......@@ -25,7 +31,7 @@ type ClueType = Static<typeof ClueSchema>;
const ShotSchema = Type.Object({
id: Type.Readonly(Type.String({ format: "uuid" })),
game_id: Type.Readonly(Type.String({ format: "uuid" })),
clue_id: Type.Optional(Type.Readonly(Type.String({ format: "uuid" }))),
clue_id: Nullable(Type.String({ format: "uuid" })),
began_at: Type.String({ format: "date-time" }),
ended_at: Type.String({ format: "date-time" }),
typed: Type.String(),
......
import fastify from "fastify";
import fastifyCors from "fastify-cors";
import { connection } from "./db";
import { FromSchema } from "json-schema-to-ts";
import fastifySwagger from "fastify-swagger";
const server = fastify({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment