@@ -9,7 +9,7 @@ import * as Reference from "./components/Reference";
9
9
import * as ConverterContext from "./ConverterContext" ;
10
10
import * as Guard from "./Guard" ;
11
11
import * as InferredType from "./InferredType" ;
12
- import { ObjectSchemaWithAdditionalProperties } from "./types" ;
12
+ import { AllOfSchema , ObjectSchemaWithAdditionalProperties } from "./types" ;
13
13
14
14
export interface ResolveReferencePath {
15
15
name : string ;
@@ -44,6 +44,19 @@ export interface Option {
44
44
useClientSchema ?: boolean ;
45
45
}
46
46
47
+ export const mergeAdhoc = (
48
+ currentPoint : string ,
49
+ schema : AllOfSchema & {
50
+ allOf : [ OpenApi . Reference , OpenApi . JSONSchema ] ;
51
+ } ,
52
+ context : Context ,
53
+ ) : OpenApi . JSONSchema => {
54
+ const [ reference , adhoc ] = schema . allOf ;
55
+ const { pathArray } = context . resolveReferencePath ( currentPoint , reference . $ref ) ;
56
+ const resolvedSchema = DotProp . get < OpenApi . JSONSchema > ( context . rootSchema , pathArray . join ( "." ) ) ;
57
+ return { ...resolvedSchema , ...adhoc } ;
58
+ } ;
59
+
47
60
export const generateMultiTypeNode = (
48
61
entryPoint : string ,
49
62
currentPoint : string ,
@@ -137,6 +150,10 @@ export const convert: Convert = (
137
150
return convert ( entryPoint , reference . referencePoint , factory , reference . data , context , converterContext , { ...option , parent : schema } ) ;
138
151
}
139
152
153
+ if ( Guard . isAdhocAllOfSchema ( schema ) ) {
154
+ return convert ( entryPoint , currentPoint , factory , mergeAdhoc ( currentPoint , schema , context ) , context , converterContext , option ) ;
155
+ }
156
+
140
157
if ( Guard . isOneOfSchema ( schema ) ) {
141
158
return nullable (
142
159
factory ,
0 commit comments