@@ -792,4 +792,128 @@ describe('Schema details generation', () => {
792
792
expect ( errToTest ! . message ) . to . match ( / S w a g g e r 2 .0 d o e s n o t s u p p o r t " o p e n I d C o n n e c t " s e c u r i t y s c h e m e / ) ;
793
793
} ) ;
794
794
} ) ;
795
+
796
+ describe ( 'Schema definitions generation' , ( ) => {
797
+ const name = 'Readonly_TestClassModel_' ;
798
+ const schema = spec . definitions ?. [ name ] ;
799
+
800
+ it ( 'should be equal to generated model' , ( ) => {
801
+ expect ( schema ) . to . deep . eq ( {
802
+ properties : {
803
+ account : { $ref : '#/definitions/Account' , format : undefined , description : undefined , example : undefined } ,
804
+ defaultValue2 : { type : 'string' , default : 'Default Value 2' , description : undefined , format : undefined , example : undefined } ,
805
+ enumKeys : {
806
+ default : undefined ,
807
+ description : undefined ,
808
+ enum : [ 'OK' , 'KO' ] ,
809
+ example : undefined ,
810
+ format : undefined ,
811
+ type : 'string' ,
812
+ 'x-nullable' : false ,
813
+ } ,
814
+ keyInterface : { type : 'string' , default : undefined , description : undefined , format : undefined , example : undefined , enum : [ 'id' ] , 'x-nullable' : false } ,
815
+ indexedType : { type : 'string' , default : undefined , description : undefined , format : undefined , example : undefined } ,
816
+ indexedTypeToInterface : { $ref : '#/definitions/IndexedInterface' , description : undefined , format : undefined , example : undefined } ,
817
+ indexedTypeToClass : { $ref : '#/definitions/IndexedClass' , description : undefined , format : undefined , example : undefined } ,
818
+ indexedTypeToAlias : { $ref : '#/definitions/IndexedInterface' , description : undefined , format : undefined , example : undefined } ,
819
+ indexedResponse : {
820
+ $ref : '#/definitions/Record_id.string_' ,
821
+ description : undefined ,
822
+ example : undefined ,
823
+ format : undefined ,
824
+ } ,
825
+ indexedResponseObject : {
826
+ $ref : '#/definitions/Record_id._myProp1-string__' ,
827
+ description : undefined ,
828
+ example : undefined ,
829
+ format : undefined ,
830
+ } ,
831
+ arrayUnion : {
832
+ default : undefined ,
833
+ description : undefined ,
834
+ enum : [ 'foo' , 'bar' ] ,
835
+ example : undefined ,
836
+ format : undefined ,
837
+ type : 'string' ,
838
+ 'x-nullable' : false ,
839
+ } ,
840
+ objectUnion : {
841
+ default : undefined ,
842
+ description : undefined ,
843
+ enum : [ 'foo' , 'bar' ] ,
844
+ example : undefined ,
845
+ format : undefined ,
846
+ type : 'string' ,
847
+ 'x-nullable' : false ,
848
+ } ,
849
+ publicStringProperty : {
850
+ type : 'string' ,
851
+ minLength : 3 ,
852
+ maxLength : 20 ,
853
+ pattern : '^[a-zA-Z]+$' ,
854
+ default : undefined ,
855
+ description : 'This is a description of a public string property' ,
856
+ format : undefined ,
857
+ example : 'classPropExample' ,
858
+ title : 'Example title' ,
859
+ } ,
860
+ optionalPublicStringProperty : { type : 'string' , minLength : 0 , maxLength : 10 , default : undefined , description : undefined , format : undefined , example : undefined } ,
861
+ emailPattern : {
862
+ type : 'string' ,
863
+ default : undefined ,
864
+ description : undefined ,
865
+ format : 'email' ,
866
+ pattern : '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$' ,
867
+ example : undefined ,
868
+ } ,
869
+ stringProperty : { type : 'string' , default : undefined , description : undefined , format : undefined , example : undefined } ,
870
+ deprecated1 : { type : 'boolean' , default : undefined , description : undefined , format : undefined , example : undefined , 'x-deprecated' : true } ,
871
+ deprecated2 : { type : 'boolean' , default : undefined , description : undefined , format : undefined , example : undefined , 'x-deprecated' : true } ,
872
+ extensionTest : { type : 'boolean' , default : undefined , description : undefined , format : undefined , example : undefined , 'x-key-1' : 'value-1' , 'x-key-2' : 'value-2' } ,
873
+ extensionComment : { type : 'boolean' , default : undefined , description : undefined , format : undefined , example : undefined , 'x-key-1' : 'value-1' , 'x-key-2' : 'value-2' } ,
874
+ stringExample : { type : 'string' , default : undefined , description : undefined , format : undefined , example : 'stringValue' } ,
875
+ objectExample : {
876
+ type : 'object' ,
877
+ default : undefined ,
878
+ description : undefined ,
879
+ format : undefined ,
880
+ example : {
881
+ id : 1 ,
882
+ label : 'labelValue' ,
883
+ } ,
884
+ properties : {
885
+ id : {
886
+ default : undefined ,
887
+ description : undefined ,
888
+ example : undefined ,
889
+ format : 'double' ,
890
+ type : 'number' ,
891
+ } ,
892
+ label : {
893
+ default : undefined ,
894
+ description : undefined ,
895
+ example : undefined ,
896
+ format : undefined ,
897
+ type : 'string' ,
898
+ } ,
899
+ } ,
900
+ required : [ 'label' , 'id' ] ,
901
+ } ,
902
+ publicConstructorVar : { type : 'string' , default : undefined , description : 'This is a description for publicConstructorVar' , format : undefined , example : undefined } ,
903
+ readonlyConstructorArgument : { type : 'string' , default : undefined , description : undefined , format : undefined , example : undefined } ,
904
+ optionalPublicConstructorVar : { type : 'string' , default : undefined , description : undefined , format : undefined , example : undefined } ,
905
+ deprecatedPublicConstructorVar : { type : 'boolean' , default : undefined , description : undefined , format : undefined , example : undefined , 'x-deprecated' : true } ,
906
+ deprecatedPublicConstructorVar2 : { type : 'boolean' , default : undefined , description : undefined , format : undefined , example : undefined , 'x-deprecated' : true } ,
907
+ id : { type : 'number' , format : 'double' , default : undefined , description : undefined , example : undefined } ,
908
+ defaultValue1 : { type : 'string' , default : 'Default Value 1' , description : undefined , format : undefined , example : undefined } ,
909
+ } ,
910
+ required : [ 'account' , 'enumKeys' , 'publicStringProperty' , 'stringProperty' , 'publicConstructorVar' , 'readonlyConstructorArgument' , 'id' ] ,
911
+ type : 'object' ,
912
+ default : undefined ,
913
+ example : undefined ,
914
+ format : undefined ,
915
+ description : 'Make all properties in T readonly' ,
916
+ } ) ;
917
+ } ) ;
918
+ } ) ;
795
919
} ) ;
0 commit comments