@@ -87,7 +87,33 @@ describe("schemaToTypeAliasDeclaration", () => {
8787 } ,
8888 } ;
8989
90- expect ( printSchema ( schema , "schemas" , components , true ) )
90+ expect ( printSchema ( schema , "Test" , "schemas" , components , true ) )
91+ . toMatchInlineSnapshot ( `
92+ "export type Test = {
93+ status?: TestStatus;
94+ };"
95+ ` ) ;
96+ } ) ;
97+
98+ it ( "should reference created enum with pascal typename" , ( ) => {
99+ const schema : SchemaObject = {
100+ type : "object" ,
101+ properties : {
102+ status : {
103+ type : "string" ,
104+ enum : [ "AVAILABLE" , "PENDING" , "SOLD" ] ,
105+ } ,
106+ } ,
107+ xml : { name : "pet" } ,
108+ } ;
109+
110+ const components : OpenAPIObject [ "components" ] = {
111+ schemas : {
112+ Pet : schema ,
113+ } ,
114+ } ;
115+
116+ expect ( printSchema ( schema , "test" , "schemas" , components , true ) )
91117 . toMatchInlineSnapshot ( `
92118 "export type Test = {
93119 status?: TestStatus;
@@ -348,7 +374,7 @@ describe("schemaToTypeAliasDeclaration", () => {
348374 $ref : "#/components/schemas/User" ,
349375 } ;
350376
351- expect ( printSchema ( schema , "parameters" ) ) . toMatchInlineSnapshot (
377+ expect ( printSchema ( schema , "Test" , " parameters") ) . toMatchInlineSnapshot (
352378 `"export type Test = Schemas.User;"` ,
353379 ) ;
354380 } ) ;
@@ -523,7 +549,7 @@ describe("schemaToTypeAliasDeclaration", () => {
523549
524550 it ( "should omit the base value if present" , ( ) => {
525551 expect (
526- printSchema ( schema , "schemas" , {
552+ printSchema ( schema , "Test" , " schemas", {
527553 schemas : {
528554 Foo : {
529555 type : "object" ,
@@ -563,7 +589,7 @@ describe("schemaToTypeAliasDeclaration", () => {
563589
564590 it ( "should not add the `Omit` if not necessary" , ( ) => {
565591 expect (
566- printSchema ( schema , "schemas" , {
592+ printSchema ( schema , "Test" , " schemas", {
567593 schemas : {
568594 Foo : { type : "object" , properties : { foo : { type : "string" } } } ,
569595 Bar : { type : "object" , properties : { bar : { type : "string" } } } ,
@@ -583,7 +609,7 @@ describe("schemaToTypeAliasDeclaration", () => {
583609
584610 it ( "should use the original type if compliant" , ( ) => {
585611 expect (
586- printSchema ( schema , "schemas" , {
612+ printSchema ( schema , "Test" , " schemas", {
587613 schemas : {
588614 Foo : {
589615 type : "object" ,
@@ -724,7 +750,8 @@ describe("schemaToTypeAliasDeclaration", () => {
724750 } ,
725751 } ;
726752
727- expect ( printSchema ( schema , undefined , components ) ) . toMatchInlineSnapshot ( `
753+ expect ( printSchema ( schema , "Test" , undefined , components ) )
754+ . toMatchInlineSnapshot ( `
728755 "export type Test = Foo & {
729756 bar?: number;
730757 };"
@@ -747,7 +774,8 @@ describe("schemaToTypeAliasDeclaration", () => {
747774 } ,
748775 } ;
749776
750- expect ( printSchema ( schema , undefined , components ) ) . toMatchInlineSnapshot ( `
777+ expect ( printSchema ( schema , "Test" , undefined , components ) )
778+ . toMatchInlineSnapshot ( `
751779 "export type Test = {
752780 bar: string;
753781 };"
@@ -972,12 +1000,13 @@ describe("schemaToTypeAliasDeclaration", () => {
9721000
9731001const printSchema = (
9741002 schema : SchemaObject ,
1003+ schemaName : string = "Test" ,
9751004 currentComponent : OpenAPIComponentType = "schemas" ,
9761005 components ?: OpenAPIObject [ "components" ] ,
9771006 useEnums ?: boolean ,
9781007) => {
9791008 const nodes = schemaToTypeAliasDeclaration (
980- "Test" ,
1009+ schemaName ,
9811010 schema ,
9821011 {
9831012 currentComponent,
0 commit comments