Skip to content

Commit

Permalink
feat: 이제 태그 붙일 수 있음!
Browse files Browse the repository at this point in the history
  • Loading branch information
potados99 committed Nov 27, 2022
1 parent 9abe0b1 commit d1f1b5f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/server/libs/SpecStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import fetch from 'isomorphic-fetch';
import path from 'path';

type Spec = {
tags?: string[];
summary?: string;
description?: string;
method: string;
Expand Down Expand Up @@ -60,6 +61,7 @@ class SpecStorage {
const thisSpec = this.specs.find(s => s.path === path && s.method === method)!!;

thisPathPart[method] = {
tags: thisSpec.tags,
summary: thisSpec.summary,
description: thisSpec.description,
parameters: this.generateParameters(thisSpec),
Expand Down
3 changes: 2 additions & 1 deletion src/server/libs/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import SpecStorage from './SpecStorage';
export function defineRoute<TParams = any, TQuery = any, TBody = any, TResponse = any>(
method: 'all' | 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head',
path: string,
schema: RequestValidation<TParams, TQuery, TBody> & { summary?: string; description?: string; response?: ZodSchema<TResponse, ZodTypeDef, any> | ZodArray<any> },
schema: RequestValidation<TParams, TQuery, TBody> & { tags?: string[], summary?: string; description?: string; response?: ZodSchema<TResponse, ZodTypeDef, any> | ZodArray<any> },
...handlers: RequestHandler<TParams, any, TBody, TQuery>[]
): express.Router {

SpecStorage.addSpec({
method: method,
path: path,

tags: schema.tags,
summary: schema.summary,
description: schema.description,

Expand Down
2 changes: 2 additions & 0 deletions src/server/libs/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type RawSchema<TParams extends ZodRawShape,
TBody extends ZodRawShape,
TObjectResponse extends ZodRawShape,
TArrayResponse extends ZodArrayOfRawShape> = {
tags?: string[];
summary?: string;
description?: string;

Expand All @@ -22,6 +23,7 @@ export function defineSchema<TParams extends ZodRawShape,
TObjectResponse extends ZodRawShape,
TArrayResponse extends ZodArrayOfRawShape>(raw: RawSchema<TParams, TQuery, TBody, TObjectResponse, TArrayResponse>) {
return {
tags: raw.tags,
summary: raw.summary,
description: raw.description,

Expand Down

0 comments on commit d1f1b5f

Please sign in to comment.