Skip to content

Commit

Permalink
Optimise Types (#288)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
samchungy and dependabot[bot] authored Jun 19, 2024
1 parent ccd38da commit 0bf55ed
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
23 changes: 21 additions & 2 deletions scripts/copyTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,30 @@ async function copyDTs(src: string, dest: string): Promise<void> {

const contents = (await fs.readFile(destination)).toString('utf-8');
if (contents.includes('export { Server, ServerVariable }')) {
const patched = contents
.replaceAll(/export \{ Server, ServerVariable \}.*/g, '')
.replaceAll(/.*\.\/dsl\/openapi-builder.*/g, '');
await fs.writeFile(destination, Buffer.from(patched));
continue;
}
if (
contents.includes(
", SpecificationExtension } from './specification-extension';",
)
) {
const patched = contents
.replace(', SpecificationExtension }', ' }')
.replaceAll(/.*export declare function.*\n/g, '');
await fs.writeFile(destination, Buffer.from(patched));
continue;
}
if (contents.includes('export declare function getExtension')) {
const patched = contents.replaceAll(
'export { Server, ServerVariable }',
'export type { Server, ServerVariable }',
/.*export declare function.*\n/g,
'',
);
await fs.writeFile(destination, Buffer.from(patched));
continue;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/openapi3-ts/dist/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * as oas30 from "./oas30";
export * as oas31 from "./oas31";
export type { Server, ServerVariable } from "./model/server";

2 changes: 0 additions & 2 deletions src/openapi3-ts/dist/model/oas-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ export interface ServerVariableObject extends ISpecificationExtension {
default: string | boolean | number;
description?: string;
}
export declare function getExtension(obj: ISpecificationExtension | undefined, extensionName: string): any;
export declare function addExtension(obj: ISpecificationExtension | undefined, extensionName: string, extension: any): void;
5 changes: 1 addition & 4 deletions src/openapi3-ts/dist/model/openapi30.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ServerObject } from './oas-common';
import { ISpecificationExtension } from './specification-extension';
export * from './oas-common';
export type { ISpecificationExtension, SpecificationExtension } from './specification-extension';
export type { ISpecificationExtension } from './specification-extension';
export interface OpenAPIObject extends ISpecificationExtension {
openapi: string;
info: InfoObject;
Expand Down Expand Up @@ -62,7 +62,6 @@ export interface PathsObject extends ISpecificationExtension {
[path: string]: PathItemObject;
}
export type PathObject = PathsObject;
export declare function getPath(pathsObject: PathsObject, path: string): PathItemObject | undefined;
export interface PathItemObject extends ISpecificationExtension {
$ref?: string;
summary?: string;
Expand Down Expand Up @@ -200,7 +199,6 @@ export interface ExamplesObject {
export interface ReferenceObject {
$ref: string;
}
export declare function isReferenceObject(obj: any): obj is ReferenceObject;
export type SchemaObjectType = 'integer' | 'number' | 'string' | 'boolean' | 'object' | 'null' | 'array';
export type SchemaObjectFormat = 'int32' | 'int64' | 'float' | 'double' | 'byte' | 'binary' | 'date' | 'date-time' | 'password' | string;
export interface SchemaObject extends ISpecificationExtension {
Expand Down Expand Up @@ -243,7 +241,6 @@ export interface SchemaObject extends ISpecificationExtension {
required?: string[];
enum?: any[];
}
export declare function isSchemaObject(schema: SchemaObject | ReferenceObject): schema is SchemaObject;
export interface SchemasObject {
[schema: string]: SchemaObject;
}
Expand Down
5 changes: 1 addition & 4 deletions src/openapi3-ts/dist/model/openapi31.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ServerObject } from './oas-common';
import { ISpecificationExtension } from './specification-extension';
export * from './oas-common';
export type { ISpecificationExtension, SpecificationExtension } from './specification-extension';
export type { ISpecificationExtension } from './specification-extension';
export interface OpenAPIObject extends ISpecificationExtension {
openapi: string;
info: InfoObject;
Expand Down Expand Up @@ -64,7 +64,6 @@ export interface PathsObject extends ISpecificationExtension {
[path: string]: PathItemObject;
}
export type PathObject = PathsObject;
export declare function getPath(pathsObject: PathsObject | undefined, path: string): PathItemObject | undefined;
export interface PathItemObject extends ISpecificationExtension {
$ref?: string;
summary?: string;
Expand Down Expand Up @@ -204,7 +203,6 @@ export interface ReferenceObject {
summary?: string;
description?: string;
}
export declare function isReferenceObject(obj: any): obj is ReferenceObject;
export type SchemaObjectType = 'integer' | 'number' | 'string' | 'boolean' | 'object' | 'null' | 'array';
export interface SchemaObject extends ISpecificationExtension {
discriminator?: DiscriminatorObject;
Expand Down Expand Up @@ -250,7 +248,6 @@ export interface SchemaObject extends ISpecificationExtension {
contentMediaType?: string;
contentEncoding?: string;
}
export declare function isSchemaObject(schema: SchemaObject | ReferenceObject): schema is SchemaObject;
export interface SchemasObject {
[schema: string]: SchemaObject;
}
Expand Down
4 changes: 2 additions & 2 deletions src/openapi3-ts/dist/oas30.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './dsl/openapi-builder30';

export * from './model/openapi30';
export type { Server, ServerVariable } from './model/server';

export type { IExtensionName, IExtensionType, ISpecificationExtension } from './model/specification-extension';
4 changes: 2 additions & 2 deletions src/openapi3-ts/dist/oas31.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './dsl/openapi-builder31';

export * from './model/openapi31';
export type { Server, ServerVariable } from './model/server';

export type { IExtensionName, IExtensionType, ISpecificationExtension } from './model/specification-extension';

0 comments on commit 0bf55ed

Please sign in to comment.