@@ -4,9 +4,7 @@ import { schemaToOpenAPI } from '../../src/openapi';
44import { OpenAPIV3 } from 'openapi-types' ;
55import { Schema } from '../../src/ir' ;
66
7- // Test numeric constraints
87test ( 'numeric constraints are properly mapped' , ( ) => {
9- // Create a schema with numeric constraints
108 const schema : Schema = {
119 type : 'number' ,
1210 minimum : 0 ,
@@ -22,19 +20,15 @@ test('numeric constraints are properly mapped', () => {
2220
2321 const result = schemaToOpenAPI ( schema ) as OpenAPIV3 . SchemaObject ;
2422
25- // Check that the result has the correct type and description
2623 assert . equal ( result . type , 'number' ) ;
2724 assert . equal ( result . description , 'A number with constraints' ) ;
2825
29- // Check that the constraints are properly mapped
3026 assert . equal ( result . minimum , 0 ) ;
3127 assert . equal ( result . maximum , 100 ) ;
3228 assert . equal ( result . multipleOf , 5 ) ;
3329} ) ;
3430
35- // Test exclusive constraints
3631test ( 'exclusive numeric constraints are properly mapped' , ( ) => {
37- // Create a schema with exclusive constraints
3832 const schema : Schema = {
3933 type : 'number' ,
4034 minimum : 0 ,
@@ -51,20 +45,16 @@ test('exclusive numeric constraints are properly mapped', () => {
5145
5246 const result = schemaToOpenAPI ( schema ) as OpenAPIV3 . SchemaObject ;
5347
54- // Check that the result has the correct type and description
5548 assert . equal ( result . type , 'number' ) ;
5649 assert . equal ( result . description , 'A number with exclusive constraints' ) ;
5750
58- // Check that the constraints are properly mapped
5951 assert . equal ( result . minimum , 0 ) ;
6052 assert . equal ( result . maximum , 100 ) ;
6153 assert . equal ( result . exclusiveMinimum , true ) ;
6254 assert . equal ( result . exclusiveMaximum , true ) ;
6355} ) ;
6456
65- // Test string-encoded numeric types
6657test ( 'string-encoded numeric types are properly mapped' , ( ) => {
67- // Create a schema for a string-encoded number
6858 const schema : Schema = {
6959 type : 'string' ,
7060 format : 'number' ,
@@ -73,13 +63,10 @@ test('string-encoded numeric types are properly mapped', () => {
7363
7464 const result = schemaToOpenAPI ( schema ) as OpenAPIV3 . SchemaObject ;
7565
76- // Check that the result has the correct type
7766 assert . equal ( result . type , 'number' ) ;
7867} ) ;
7968
80- // Test string-encoded integer types
8169test ( 'string-encoded integer types are properly mapped' , ( ) => {
82- // Create a schema for a string-encoded integer
8370 const schema : Schema = {
8471 type : 'string' ,
8572 format : 'integer' ,
@@ -88,13 +75,10 @@ test('string-encoded integer types are properly mapped', () => {
8875
8976 const result = schemaToOpenAPI ( schema ) as OpenAPIV3 . SchemaObject ;
9077
91- // Check that the result has the correct type
9278 assert . equal ( result . type , 'integer' ) ;
9379} ) ;
9480
95- // Test BigInt types
9681test ( 'BigInt types are properly mapped' , ( ) => {
97- // Create a schema for a BigInt
9882 const schema : Schema = {
9983 type : 'string' ,
10084 format : 'number' ,
@@ -103,14 +87,11 @@ test('BigInt types are properly mapped', () => {
10387
10488 const result = schemaToOpenAPI ( schema ) as OpenAPIV3 . SchemaObject ;
10589
106- // Check that the result has the correct type and format
10790 assert . equal ( result . type , 'integer' ) ;
10891 assert . equal ( result . format , 'int64' ) ;
10992} ) ;
11093
111- // Test BigInt types with constraints
11294test ( 'BigInt types with constraints are properly mapped' , ( ) => {
113- // Create a schema for a BigInt with constraints
11495 const schema : Schema = {
11596 type : 'string' ,
11697 format : 'number' ,
@@ -121,7 +102,6 @@ test('BigInt types with constraints are properly mapped', () => {
121102
122103 const result = schemaToOpenAPI ( schema ) as OpenAPIV3 . SchemaObject ;
123104
124- // Check that the result has the correct type, format, and constraints
125105 assert . equal ( result . type , 'integer' ) ;
126106 assert . equal ( result . format , 'int64' ) ;
127107 assert . equal ( result . minimum , 0 ) ;
0 commit comments