File tree 3 files changed +13
-3
lines changed
3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 1
1
import deepEqual from "fast-deep-equal" ;
2
2
import { fromSchema , fromParameter } from "./lib/convert" ;
3
- import type { Options , OptionsInternal , OpenAPI3 } from "./openapi-schema-types" ;
3
+ import type { Options , OptionsInternal } from "./openapi-schema-types" ;
4
4
import { NOT_SUPPORTED , STRUCTS } from "./consts" ;
5
5
import type { JSONSchema4 } from "json-schema" ;
6
6
import type { ParameterObject , ResponseObject } from "openapi-typescript/src/types" ;
7
7
import { cloneDeep } from "./lib/utils/cloneDeep" ;
8
+ import type { AcceptibleInputSchema } from "./openapi-schema-types" ;
9
+
8
10
const patternPropertiesHandler = ( schema ) => {
9
11
let pattern ;
10
12
const patternsObj = schema . patternProperties ;
@@ -56,7 +58,10 @@ const resolveOptions = (_options?: Options): OptionsInternal => {
56
58
return options ;
57
59
} ;
58
60
59
- const openapiSchemaToJsonSchema = < T extends OpenAPI3 = OpenAPI3 > ( schema : T , options ?: Options ) : JSONSchema4 => {
61
+ const openapiSchemaToJsonSchema = < T extends AcceptibleInputSchema = AcceptibleInputSchema > (
62
+ schema : T ,
63
+ options ?: Options ,
64
+ ) : JSONSchema4 => {
60
65
const optionsInternal = resolveOptions ( options ) ;
61
66
return fromSchema < T > ( schema , optionsInternal ) ;
62
67
} ;
Original file line number Diff line number Diff line change @@ -8,9 +8,13 @@ import type { PatternPropertiesHandler } from "../../openapi-schema-types";
8
8
import type { OpenAPI3 } from "openapi-typescript" ;
9
9
import type { ReferenceObject } from "openapi-typescript/src/types" ;
10
10
import { cloneDeep } from "../utils/cloneDeep" ;
11
+ import type { AcceptibleInputSchema } from "../../openapi-schema-types" ;
11
12
12
13
// Convert from OpenAPI 3.0 `SchemaObject` to JSON schema v4
13
- function convertFromSchema < T extends OpenAPI3 = OpenAPI3 > ( schema : T , options : OptionsInternal ) : JSONSchema4 {
14
+ function convertFromSchema < T extends AcceptibleInputSchema = AcceptibleInputSchema > (
15
+ schema : T ,
16
+ options : OptionsInternal ,
17
+ ) : JSONSchema4 {
14
18
const newSchema = convertSchema ( schema , options ) ;
15
19
( < JSONSchema4 > newSchema ) . $schema = "http://json-schema.org/draft-04/schema#" ;
16
20
return newSchema ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import type { JSONSchema4 } from "json-schema";
6
6
export type { OpenAPI3 } ;
7
7
// We don't know what the shape of the object looks like when it's passed in, but we know its some mix of these two
8
8
export type PatternPropertiesHandler = ( schema : SchemaObject ) => SchemaObject ;
9
+ export type AcceptibleInputSchema = SchemaObject | OpenAPI3 | Record < string , any > ;
9
10
10
11
export interface Options {
11
12
dateToDateTime ?: boolean ;
You can’t perform that action at this time.
0 commit comments