Skip to content

Commit 1a6653b

Browse files
danielsharveytheoomoregbee
authored andcommitted
fix: Correct and improve OpenAPI3 Typescript interface def for Parameter
1 parent aeda736 commit 1a6653b

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

types/openapi.d.ts

+25-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
import { Reference, Header, Tag, ExternalDocs, XML } from 'swagger-schema-official';
2+
import { Reference, Tag, ExternalDocs, XML } from 'swagger-schema-official';
33

44
// This is simply building from OpenApi Specification
55
// see: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md
@@ -77,16 +77,32 @@ declare namespace OpenApi {
7777
enum?: any[];
7878
}
7979

80-
export interface Parameter {
81-
name: string;
82-
in: string;
83-
description?: string;
84-
required?: boolean;
85-
deprecated?: boolean;
86-
allowEmptyValue?: boolean;
87-
schema?: UpdatedSchema | Reference;
80+
export type ParameterLocation = 'query' | 'header' | 'path' | 'cookie';
81+
82+
export type ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
83+
84+
export interface ParameterCommon {
85+
description?: string;
86+
required?: boolean;
87+
deprecated?: boolean;
88+
allowEmptyValue?: boolean;
89+
90+
style?: ParameterStyle;
91+
explode?: boolean;
92+
allowReserved?: boolean;
93+
schema?: UpdatedSchema | Reference;
94+
examples?: Map<string, Example | Reference>;
95+
example?: any;
96+
content?: Record<string, MediaType>;
97+
}
98+
99+
export interface Parameter extends ParameterCommon {
100+
name: string;
101+
in: ParameterLocation;
88102
}
89103

104+
export type Header = ParameterCommon
105+
90106
export interface Example {
91107
summary?: string;
92108
description?: string;

0 commit comments

Comments
 (0)