Skip to content

Commit

Permalink
Refactoring of XParameterObject and XHeaderObject
Browse files Browse the repository at this point in the history
  • Loading branch information
KostyaTretyak committed Mar 26, 2021
1 parent 82e96f2 commit 3b280f1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 96 deletions.
90 changes: 0 additions & 90 deletions versions/3.1/src/extended/base-parameter-object.ts

This file was deleted.

14 changes: 12 additions & 2 deletions versions/3.1/src/extended/header-object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { XBaseParameterObject } from './base-parameter-object';
import { BaseParameterObject } from '../origin/base-parameter-object';
import { SpecExtFieldPattern, SpecificationExtension } from '../origin/specification-extension';
import { XExampleObject } from './example-object';
import { XMediaTypeObject } from './media-type-object';
import { XReferenceObject } from './reference-object';
import { XSchemaObject } from './schema-object';

/**
* The Header Object follows the structure of the [Parameter Object][1] with the following changes:
Expand Down Expand Up @@ -34,7 +39,9 @@ schema:
* [1]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameterObject
* [2]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameterStyle
*/
export interface XHeaderObject extends XBaseParameterObject {
export type XHeaderObject<T extends SpecExtFieldPattern = any> = SpecificationExtension<T> & ExtendedHeaderObject;

interface ExtendedHeaderObject extends BaseParameterObject {
/**
* MUST NOT be specified, it is given in the corresponding `headers` map.
*/
Expand All @@ -43,4 +50,7 @@ export interface XHeaderObject extends XBaseParameterObject {
* MUST NOT be specified, it is implicitly in `header`.
*/
in?: never;
schema?: XSchemaObject;
examples?: { [exampleName: string]: XExampleObject | XReferenceObject };
content?: { [mediaTypeName: string]: XMediaTypeObject };
}
14 changes: 12 additions & 2 deletions versions/3.1/src/extended/parameter-object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { XBaseParameterObject } from './base-parameter-object';
import { BaseParameterObject } from '../origin/base-parameter-object';
import { SpecExtFieldPattern, SpecificationExtension } from '../origin/specification-extension';
import { XExampleObject } from './example-object';
import { XMediaTypeObject } from './media-type-object';
import { XReferenceObject } from './reference-object';
import { XSchemaObject } from './schema-object';

/**
* Describes a single operation parameter.
Expand Down Expand Up @@ -218,7 +223,9 @@ content:
* [7]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameterContent
* [8]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#specificationExtensions
*/
export interface XParameterObject extends XBaseParameterObject {
export type XParameterObject<T extends SpecExtFieldPattern = any> = SpecificationExtension<T> & ExtendedParameterObject;

interface ExtendedParameterObject extends BaseParameterObject {
/**
* The name of the parameter. Parameter names are *case sensitive*.
* - If [`in`][1] is `"path"`, the `name` field MUST correspond to a template expression
Expand All @@ -240,4 +247,7 @@ export interface XParameterObject extends XBaseParameterObject {
* or `"cookie"`.
*/
in: 'query' | 'header' | 'path' | 'cookie';
schema?: XSchemaObject;
examples?: { [exampleName: string]: XExampleObject | XReferenceObject };
content?: { [mediaTypeName: string]: XMediaTypeObject };
}
4 changes: 2 additions & 2 deletions versions/3.1/tests/static-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OasObject, OAuthFlowsObject } from '..';
import { XOasObject } from '..';

const oasObject: OasObject = {
const oasObject: XOasObject = {
openapi: '3.0.1',
info: {
title: 'Swagger Petstore',
Expand Down

0 comments on commit 3b280f1

Please sign in to comment.