@@ -8,7 +8,7 @@ import { Swagger2 } from '../src/swagger-2';
8
8
// Let Prettier handle formatting, not the test expectations
9
9
function format ( spec : string , namespaced ?: boolean ) {
10
10
const wrapped = namespaced === false ? spec : `namespace OpenAPI2 { ${ spec } }` ;
11
- return prettier . format ( wrapped , { parser : 'typescript' } ) ;
11
+ return prettier . format ( wrapped , { parser : 'typescript' , singleQuote : true } ) ;
12
12
}
13
13
14
14
describe ( 'Swagger 2 spec' , ( ) => {
@@ -249,6 +249,44 @@ describe('Swagger 2 spec', () => {
249
249
} ) ;
250
250
} ) ;
251
251
252
+ it ( 'can deal with additionalProperties: true' , ( ) => {
253
+ const swagger : Swagger2 = {
254
+ definitions : {
255
+ FeatureMap : {
256
+ type : 'object' ,
257
+ additionalProperties : true ,
258
+ } ,
259
+ } ,
260
+ } ;
261
+
262
+ const ts = format ( `
263
+ export interface FeatureMap {
264
+ [name: string]: any;
265
+ }` ) ;
266
+
267
+ expect ( swaggerToTS ( swagger ) ) . toBe ( ts ) ;
268
+ } ) ;
269
+
270
+ it ( 'can deal with additionalProperties of type' , ( ) => {
271
+ const swagger : Swagger2 = {
272
+ definitions : {
273
+ Credentials : {
274
+ type : 'object' ,
275
+ additionalProperties : {
276
+ type : 'string' ,
277
+ } ,
278
+ } ,
279
+ } ,
280
+ } ;
281
+
282
+ const ts = format ( `
283
+ export interface Credentials {
284
+ [name: string]: string;
285
+ }` ) ;
286
+
287
+ expect ( swaggerToTS ( swagger ) ) . toBe ( ts ) ;
288
+ } ) ;
289
+
252
290
describe ( 'other output' , ( ) => {
253
291
it ( 'generates the example output correctly' , ( ) => {
254
292
const input = yaml . safeLoad (
0 commit comments