Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
export type TPathItemObject = {
$ref: Option;
get: Option;
put: Option;
post: Option;
delete: Option;
options: Option;
head: Option;
patch: Option;
parameters: Option>;
};
export const PathItemObject: t.Type = t.type({
$ref: stringOption,
get: createOptionFromNullable(OperationObject),
put: createOptionFromNullable(OperationObject),
post: createOptionFromNullable(OperationObject),
delete: createOptionFromNullable(OperationObject),
options: createOptionFromNullable(OperationObject),
head: createOptionFromNullable(OperationObject),
patch: createOptionFromNullable(OperationObject),
parameters: createOptionFromNullable(t.array(t.union([ParameterObject, ReferenceObject]))),
});
export type TPathsObject = TDictionary;
export const PathsObject: t.Type = t.dictionary(t.string, PathItemObject);
export type TParametersDefinitionsObject = TDictionary;
export const ParametersDefinitionsObject: t.Type = t.dictionary(
t.string,
ParameterObject,
produces: Option;
responses: Option;
schemes: Option;
security: Option;
securityDefinitions: Option;
swagger: string;
tags: Option;
};
export const SwaggerObject: t.Type = t.type({
basePath: stringOption,
consumes: stringArrayOption,
definitions: createOptionFromNullable(DefinitionsObject),
externalDocs: createOptionFromNullable(ExternalDocumentationObject),
host: stringOption,
info: InfoObject,
parameters: createOptionFromNullable(ParametersDefinitionsObject),
paths: PathsObject,
produces: stringArrayOption,
responses: createOptionFromNullable(ResponsesDefinitionsObject),
schemes: stringArrayOption,
security: createOptionFromNullable(t.array(SecurityRequirementObject)),
securityDefinitions: createOptionFromNullable(SecurityDefinitionsObject),
swagger: t.string,
tags: createOptionFromNullable(t.array(TagObject)),
});
SchemaObject => {
const ArraySchemaObject: t.Tagged<'type', TArraySchemaObject, mixed> = t.type({
...BaseSchemaObjectProps,
type: t.literal('array'),
items: SchemaObject,
});
const ObjectSchemaObject: t.Tagged<'type', TObjectSchemaObject, mixed> = t.type({
...BaseSchemaObjectProps,
required: stringArrayOption,
type: t.literal('object'),
properties: createOptionFromNullable(t.dictionary(t.string, SchemaObject)),
additionalProperties: createOptionFromNullable(SchemaObject),
});
const ReferenceOrAllOfSchemaObject: t.Tagged<'type', TReferenceOrAllOfSchemeObject, mixed> = t.union([
t.intersection([
ReferenceObject,
t.type({
...BaseSchemaObjectProps,
type: t.literal(undefined as any),
}),
]),
t.type({
...BaseSchemaObjectProps,
description: stringOption,
type: t.literal(undefined as any),
allOf: t.array(SchemaObject),
}),
]);
info: TInfoObject;
parameters: Option;
paths: TPathsObject;
produces: Option;
responses: Option;
schemes: Option;
security: Option;
securityDefinitions: Option;
swagger: string;
tags: Option;
};
export const SwaggerObject: t.Type = t.type({
basePath: stringOption,
consumes: stringArrayOption,
definitions: createOptionFromNullable(DefinitionsObject),
externalDocs: createOptionFromNullable(ExternalDocumentationObject),
host: stringOption,
info: InfoObject,
parameters: createOptionFromNullable(ParametersDefinitionsObject),
paths: PathsObject,
produces: stringArrayOption,
responses: createOptionFromNullable(ResponsesDefinitionsObject),
schemes: stringArrayOption,
security: createOptionFromNullable(t.array(SecurityRequirementObject)),
securityDefinitions: createOptionFromNullable(SecurityDefinitionsObject),
swagger: t.string,
tags: createOptionFromNullable(t.array(TagObject)),
});
import * as t from 'io-ts';
import { createOptionFromNullable } from 'io-ts-types';
import { Option } from 'fp-ts/lib/Option';
import { mixed } from 'io-ts';
import { TPathParameterObject } from './swagger';
export const stringOption = createOptionFromNullable(t.string);
export const booleanOption = createOptionFromNullable(t.boolean);
export const numberOption = createOptionFromNullable(t.number);
export const stringArrayOption = createOptionFromNullable(t.array(t.string));
export const primitiveArrayOption = createOptionFromNullable(t.array(t.union([t.string, t.boolean, t.number])));
export type TDictionary<a> = {
[key: string]: A;
};
export type TContactObject = {
name: Option;
url: Option;
email: Option;
};
export const ContactObject: t.Type = t.type({
name: stringOption,
url: stringOption,
email: stringOption,
});
</a>
import * as t from 'io-ts';
import { createOptionFromNullable } from 'io-ts-types';
import { Option } from 'fp-ts/lib/Option';
import { mixed } from 'io-ts';
import { TPathParameterObject } from './swagger';
export const stringOption = createOptionFromNullable(t.string);
export const booleanOption = createOptionFromNullable(t.boolean);
export const numberOption = createOptionFromNullable(t.number);
export const stringArrayOption = createOptionFromNullable(t.array(t.string));
export const primitiveArrayOption = createOptionFromNullable(t.array(t.union([t.string, t.boolean, t.number])));
export type TDictionary<a> = {
[key: string]: A;
};
export type TContactObject = {
name: Option;
url: Option;
email: Option;
};
export const ContactObject: t.Type = t.type({
name: stringOption,
url: stringOption,
email: stringOption,</a>
get: Option;
put: Option;
post: Option;
delete: Option;
options: Option;
head: Option;
patch: Option;
parameters: Option>;
};
export const PathItemObject: t.Type = t.type({
$ref: stringOption,
get: createOptionFromNullable(OperationObject),
put: createOptionFromNullable(OperationObject),
post: createOptionFromNullable(OperationObject),
delete: createOptionFromNullable(OperationObject),
options: createOptionFromNullable(OperationObject),
head: createOptionFromNullable(OperationObject),
patch: createOptionFromNullable(OperationObject),
parameters: createOptionFromNullable(t.array(t.union([ParameterObject, ReferenceObject]))),
});
export type TPathsObject = TDictionary;
export const PathsObject: t.Type = t.dictionary(t.string, PathItemObject);
export type TParametersDefinitionsObject = TDictionary;
export const ParametersDefinitionsObject: t.Type = t.dictionary(
t.string,
ParameterObject,
);
export type TResponsesDefinitionsObject = TDictionary;
export const ResponsesDefinitionsObject: t.Type = t.dictionary(
export const SwaggerObject: t.Type = t.type({
basePath: stringOption,
consumes: stringArrayOption,
definitions: createOptionFromNullable(DefinitionsObject),
externalDocs: createOptionFromNullable(ExternalDocumentationObject),
host: stringOption,
info: InfoObject,
parameters: createOptionFromNullable(ParametersDefinitionsObject),
paths: PathsObject,
produces: stringArrayOption,
responses: createOptionFromNullable(ResponsesDefinitionsObject),
schemes: stringArrayOption,
security: createOptionFromNullable(t.array(SecurityRequirementObject)),
securityDefinitions: createOptionFromNullable(SecurityDefinitionsObject),
swagger: t.string,
tags: createOptionFromNullable(t.array(TagObject)),
});
tags: Option;
};
export const SwaggerObject: t.Type = t.type({
basePath: stringOption,
consumes: stringArrayOption,
definitions: createOptionFromNullable(DefinitionsObject),
externalDocs: createOptionFromNullable(ExternalDocumentationObject),
host: stringOption,
info: InfoObject,
parameters: createOptionFromNullable(ParametersDefinitionsObject),
paths: PathsObject,
produces: stringArrayOption,
responses: createOptionFromNullable(ResponsesDefinitionsObject),
schemes: stringArrayOption,
security: createOptionFromNullable(t.array(SecurityRequirementObject)),
securityDefinitions: createOptionFromNullable(SecurityDefinitionsObject),
swagger: t.string,
tags: createOptionFromNullable(t.array(TagObject)),
});
});
export type TInfoObject = {
title: string;
description: Option;
termsOfService: Option;
contact: Option;
license: Option;
version: string;
};
export const InfoObject: t.Type = t.type({
title: t.string,
description: stringOption,
termsOfService: stringOption,
contact: createOptionFromNullable(ContactObject),
license: createOptionFromNullable(LicenseObject),
version: t.string,
});
export type TExternalDocumentationObject = {
description: Option;
url: string;
};
export const ExternalDocumentationObject: t.Type = t.type({
description: stringOption,
url: t.string,
});
export type TReferenceObject = {
$ref: string;
};
export const ReferenceObject: t.Type = t.type({