From 958c9716a9d8b1bf6ff005798a0e00b13f108ec9 Mon Sep 17 00:00:00 2001 From: dblock Date: Tue, 10 Dec 2024 13:50:28 -0500 Subject: [PATCH] Extract HttpMethod. Signed-off-by: dblock --- json_schemas/test_story.schema.yaml | 13 +++++++------ tools/src/tester/types/story.types.ts | 9 ++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/json_schemas/test_story.schema.yaml b/json_schemas/test_story.schema.yaml index f1c54301..39bc7dca 100644 --- a/json_schemas/test_story.schema.yaml +++ b/json_schemas/test_story.schema.yaml @@ -67,6 +67,11 @@ definitions: items: type: integer + HttpMethod: + type: string + # eslint-disable-next-line yml/sort-sequence-values + enum: [GET, PUT, POST, DELETE, PATCH, HEAD, OPTIONS] + ChapterRequest: type: object properties: @@ -79,12 +84,8 @@ definitions: oneOf: - type: array items: - type: string - # eslint-disable-next-line yml/sort-sequence-values - enum: [GET, PUT, POST, DELETE, PATCH, HEAD, OPTIONS] - - type: string - # eslint-disable-next-line yml/sort-sequence-values - enum: [GET, PUT, POST, DELETE, PATCH, HEAD, OPTIONS] + $ref: '#/definitions/HttpMethod' + - $ref: '#/definitions/HttpMethod' parameters: type: object additionalProperties: diff --git a/tools/src/tester/types/story.types.ts b/tools/src/tester/types/story.types.ts index 7d72312c..90220577 100644 --- a/tools/src/tester/types/story.types.ts +++ b/tools/src/tester/types/story.types.ts @@ -27,6 +27,11 @@ export type SupplementalChapter = ChapterRequest & { */ status?: number[]; }; +/** + * This interface was referenced by `Story`'s JSON-Schema + * via the `definition` "HttpMethod". + */ +export type HttpMethod = 'GET' | 'PUT' | 'POST' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'; /** * This interface was referenced by `Story`'s JSON-Schema * via the `definition` "Parameter". @@ -115,9 +120,7 @@ export interface ChapterRequest { */ id?: string; path: string; - method: - | ('GET' | 'PUT' | 'POST' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS')[] - | ('GET' | 'PUT' | 'POST' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS'); + method: HttpMethod[] | HttpMethod; parameters?: { [k: string]: Parameter; };