@@ -4,17 +4,18 @@ import path from 'path';
44import { convertToTypedDict } from '../src/utils/json-schema-to-typed-dict' ;
55import { extractSchemas } from '../src/utils/extract-schemas' ;
66import child_process from 'child_process' ;
7+ import type { OpenAPIV3_1 as OpenAPI } from 'openapi-types' ;
78
89describe ( 'generate-python-dict' , ( ) => {
910 it ( 'generates a simple object schema' , ( ) => {
10- const doc : any = {
11+ const doc : OpenAPI . Document = {
1112 openapi : '3.1.0' ,
1213 info : { title : 't' , version : '1' } ,
1314 paths : { } ,
1415 components : { schemas : { User : { type : 'object' , properties : { id : { type : 'string' } } , required : [ 'id' ] } } }
1516 } ;
1617 const schemas = extractSchemas ( doc , null ) ;
17- const { definition, typingImports } = convertToTypedDict ( 'User' , schemas . User as any ) ;
18+ const { definition, typingImports } = convertToTypedDict ( 'User' , schemas . User as OpenAPI . SchemaObject ) ;
1819 const typingLine = `from typing import ${ Array . from ( typingImports ) . join ( ', ' ) } ` ;
1920 const content = [ typingLine , '' , definition , '' ] . filter ( Boolean ) . join ( '\n' ) ;
2021 const tmp = path . join ( __dirname , 'tmp_user.py' ) ;
@@ -28,7 +29,7 @@ describe('generate-python-dict', () => {
2829 } ) ;
2930
3031 it ( 'generates enums and nested arrays' , ( ) => {
31- const doc : any = {
32+ const doc : OpenAPI . Document = {
3233 openapi : '3.1.0' ,
3334 info : { title : 't' , version : '1' } ,
3435 paths : { } ,
@@ -40,7 +41,7 @@ describe('generate-python-dict', () => {
4041 }
4142 } ;
4243 const schemas = extractSchemas ( doc , null ) ;
43- const { definition, typingImports } = convertToTypedDict ( 'Wrapper' , schemas . Wrapper as any ) ;
44+ const { definition, typingImports } = convertToTypedDict ( 'Wrapper' , schemas . Wrapper as OpenAPI . SchemaObject ) ;
4445 const typingLine = `from typing import ${ Array . from ( typingImports ) . join ( ', ' ) } ` ;
4546 const content = [ typingLine , '' , definition , '' ] . filter ( Boolean ) . join ( '\n' ) ;
4647 const tmp = path . join ( __dirname , 'tmp_wrapper.py' ) ;
@@ -51,7 +52,7 @@ describe('generate-python-dict', () => {
5152 } ) ;
5253
5354 it ( 'adds descriptions as comments' , ( ) => {
54- const doc : any = {
55+ const doc : OpenAPI . Document = {
5556 openapi : '3.1.0' ,
5657 info : { title : 't' , version : '1' } ,
5758 paths : { } ,
@@ -69,12 +70,12 @@ describe('generate-python-dict', () => {
6970 }
7071 } ;
7172 const schemas = extractSchemas ( doc , null ) ;
72- const { definition } = convertToTypedDict ( 'User' , schemas . User as any ) ;
73+ const { definition } = convertToTypedDict ( 'User' , schemas . User as OpenAPI . SchemaObject ) ;
7374 expect ( definition ) . toMatchSnapshot ( ) ;
7475 } ) ;
7576
7677 it ( 'filters schemas by path prefixes' , ( ) => {
77- const doc : any = {
78+ const doc : OpenAPI . Document = {
7879 openapi : '3.1.0' ,
7980 info : { title : 't' , version : '1' } ,
8081 paths : {
0 commit comments