From e7997356b6dcbaab64e318d7aea6c09d859ff0e0 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Noblot <101098155+jbnoblot@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:48:35 +0200 Subject: [PATCH] better autocomplete with ParamsObject in v3 inspired about https://www.sheshbabu.com/posts/rust-for-javascript-developers-pattern-matching-and-enums/ --- packages/openapi-types/index.ts | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/packages/openapi-types/index.ts b/packages/openapi-types/index.ts index 5bd58b2b..48b34d4b 100644 --- a/packages/openapi-types/index.ts +++ b/packages/openapi-types/index.ts @@ -365,11 +365,32 @@ export namespace OpenAPIV3 { url: string; } - export interface ParameterObject extends ParameterBaseObject { + export type ParameterObject = PathLocationObject | QueryLocationObject | CookieLocationObject | HeaderLocationObject; + + export interface CookieLocationObject extends ParameterBaseObject { name: string; - in: string; + in: "cookie"; + style?: "form"; + } + + interface HeaderLocationObject extends ParameterBaseObject { + name: string; + in: "header"; + style?: "simple"; + } + + interface PathLocationObject extends ParameterBaseObject { + name: string; + in: "path"; + required: boolean; + style?: "matrix" | "label" | "simple"; + } + + interface QueryLocationObject extends ParameterBaseObject { + name: string; + in: "query"; + style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject"; } - export interface HeaderObject extends ParameterBaseObject {} export interface ParameterBaseObject {