File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 11import deepEqual from "fast-deep-equal" ;
22import { fromSchema , fromParameter } from "./lib/convert" ;
3- import type { Options , OptionsInternal , OpenAPI3 } from "./openapi-schema-types" ;
3+ import type { Options , OptionsInternal } from "./openapi-schema-types" ;
44import { NOT_SUPPORTED , STRUCTS } from "./consts" ;
55import type { JSONSchema4 } from "json-schema" ;
66import type { ParameterObject , ResponseObject } from "openapi-typescript/src/types" ;
77import { cloneDeep } from "./lib/utils/cloneDeep" ;
8+ import type { AcceptibleInputSchema } from "./openapi-schema-types" ;
9+
810const patternPropertiesHandler = ( schema ) => {
911 let pattern ;
1012 const patternsObj = schema . patternProperties ;
@@ -56,7 +58,10 @@ const resolveOptions = (_options?: Options): OptionsInternal => {
5658 return options ;
5759} ;
5860
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 => {
6065 const optionsInternal = resolveOptions ( options ) ;
6166 return fromSchema < T > ( schema , optionsInternal ) ;
6267} ;
Original file line number Diff line number Diff line change @@ -8,9 +8,13 @@ import type { PatternPropertiesHandler } from "../../openapi-schema-types";
88import type { OpenAPI3 } from "openapi-typescript" ;
99import type { ReferenceObject } from "openapi-typescript/src/types" ;
1010import { cloneDeep } from "../utils/cloneDeep" ;
11+ import type { AcceptibleInputSchema } from "../../openapi-schema-types" ;
1112
1213// 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 {
1418 const newSchema = convertSchema ( schema , options ) ;
1519 ( < JSONSchema4 > newSchema ) . $schema = "http://json-schema.org/draft-04/schema#" ;
1620 return newSchema ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import type { JSONSchema4 } from "json-schema";
66export type { OpenAPI3 } ;
77// 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
88export type PatternPropertiesHandler = ( schema : SchemaObject ) => SchemaObject ;
9+ export type AcceptibleInputSchema = SchemaObject | OpenAPI3 | Record < string , any > ;
910
1011export interface Options {
1112 dateToDateTime ?: boolean ;
You can’t perform that action at this time.
0 commit comments