File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { OpenApi } from '../interfaces/OpenApi' ;
2
+ import { OpenApiSchema } from '../interfaces/OpenApiSchema' ;
3
+ import { getModel } from './getModel' ;
4
+
5
+ describe ( 'getModel' , ( ) => {
6
+ it ( 'should get an object model when type is missing but properties exist' , ( ) => {
7
+ const openApi : OpenApi = {
8
+ openapi : '3.0.1' ,
9
+ info : { title : 'OpenApi Test' , version : '0.1.0' } ,
10
+ paths : { } ,
11
+ } ;
12
+ const definition : OpenApiSchema = {
13
+ properties : {
14
+ data : {
15
+ type : 'string' ,
16
+ } ,
17
+ } ,
18
+ } ;
19
+
20
+ const model = getModel ( openApi , definition ) ;
21
+ expect ( model . properties [ 0 ] . name ) . toBe ( 'data' ) ;
22
+ } ) ;
23
+ } ) ;
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ export const getModel = (
149
149
return model ;
150
150
}
151
151
152
- if ( definition . type === 'object' ) {
152
+ if ( definition . type === 'object' || definition . properties ) {
153
153
if ( definition . properties ) {
154
154
model . export = 'interface' ;
155
155
model . type = 'any' ;
You can’t perform that action at this time.
0 commit comments