Skip to content

Commit 3d247c5

Browse files
committed
move isOpenAPI2Reference to utils, as build-script crashes when it is in /types
1 parent 89fc1d0 commit 3d247c5

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

src/types/OpenAPI2.ts

-6
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ export type OpenAPI2Type =
3232

3333
export type OpenAPI2Reference = { $ref: string };
3434

35-
export function isOpenAPI2Reference(
36-
additionalProperties: OpenAPI2SchemaObject | OpenAPI2Reference | boolean
37-
): additionalProperties is OpenAPI2Reference {
38-
return (additionalProperties as OpenAPI2Reference).$ref !== undefined;
39-
}
40-
4135
export interface OpenAPI2SchemaObject {
4236
additionalProperties?: OpenAPI2SchemaObject | OpenAPI2Reference | boolean;
4337
allOf?: OpenAPI2SchemaObject[];

src/utils.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { OpenAPI2, OpenAPI3 } from "./types";
1+
import { OpenAPI2, OpenAPI2Reference, OpenAPI2SchemaObject, OpenAPI3 } from "./types";
22

33
export function comment(text: string): string {
44
return `/**
@@ -121,3 +121,9 @@ export function unrefComponent(components: any, ref: string): any {
121121
const [type, object] = ref.match(/(?<=\[")([^"]+)/g) as string[];
122122
return components[type][object];
123123
}
124+
125+
export function isOpenAPI2Reference(
126+
additionalProperties: OpenAPI2SchemaObject | OpenAPI2Reference | boolean
127+
): additionalProperties is OpenAPI2Reference {
128+
return (additionalProperties as OpenAPI2Reference).$ref !== undefined;
129+
}

src/v2.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import propertyMapper from "./property-mapper";
2-
import {
3-
OpenAPI2,
4-
OpenAPI2Reference,
5-
OpenAPI2SchemaObject,
6-
OpenAPI2Schemas,
7-
SwaggerToTSOptions,
8-
isOpenAPI2Reference,
9-
} from "./types";
10-
import { comment, nodeType, transformRef, tsArrayOf, tsIntersectionOf, tsUnionOf } from "./utils";
2+
import { OpenAPI2, OpenAPI2Reference, OpenAPI2SchemaObject, OpenAPI2Schemas, SwaggerToTSOptions } from "./types";
3+
import { comment, nodeType, transformRef, tsArrayOf, tsIntersectionOf, tsUnionOf, isOpenAPI2Reference } from "./utils";
114

125
export const PRIMITIVES: { [key: string]: "boolean" | "string" | "number" } = {
136
// boolean types

0 commit comments

Comments
 (0)