@@ -4,9 +4,7 @@ import { schemaToOpenAPI } from '../../src/openapi';
4
4
import { OpenAPIV3 } from 'openapi-types' ;
5
5
import { Schema } from '../../src/ir' ;
6
6
7
- // Test numeric constraints
8
7
test ( 'numeric constraints are properly mapped' , ( ) => {
9
- // Create a schema with numeric constraints
10
8
const schema : Schema = {
11
9
type : 'number' ,
12
10
minimum : 0 ,
@@ -22,19 +20,15 @@ test('numeric constraints are properly mapped', () => {
22
20
23
21
const result = schemaToOpenAPI ( schema ) as OpenAPIV3 . SchemaObject ;
24
22
25
- // Check that the result has the correct type and description
26
23
assert . equal ( result . type , 'number' ) ;
27
24
assert . equal ( result . description , 'A number with constraints' ) ;
28
25
29
- // Check that the constraints are properly mapped
30
26
assert . equal ( result . minimum , 0 ) ;
31
27
assert . equal ( result . maximum , 100 ) ;
32
28
assert . equal ( result . multipleOf , 5 ) ;
33
29
} ) ;
34
30
35
- // Test exclusive constraints
36
31
test ( 'exclusive numeric constraints are properly mapped' , ( ) => {
37
- // Create a schema with exclusive constraints
38
32
const schema : Schema = {
39
33
type : 'number' ,
40
34
minimum : 0 ,
@@ -51,20 +45,16 @@ test('exclusive numeric constraints are properly mapped', () => {
51
45
52
46
const result = schemaToOpenAPI ( schema ) as OpenAPIV3 . SchemaObject ;
53
47
54
- // Check that the result has the correct type and description
55
48
assert . equal ( result . type , 'number' ) ;
56
49
assert . equal ( result . description , 'A number with exclusive constraints' ) ;
57
50
58
- // Check that the constraints are properly mapped
59
51
assert . equal ( result . minimum , 0 ) ;
60
52
assert . equal ( result . maximum , 100 ) ;
61
53
assert . equal ( result . exclusiveMinimum , true ) ;
62
54
assert . equal ( result . exclusiveMaximum , true ) ;
63
55
} ) ;
64
56
65
- // Test string-encoded numeric types
66
57
test ( 'string-encoded numeric types are properly mapped' , ( ) => {
67
- // Create a schema for a string-encoded number
68
58
const schema : Schema = {
69
59
type : 'string' ,
70
60
format : 'number' ,
@@ -73,13 +63,10 @@ test('string-encoded numeric types are properly mapped', () => {
73
63
74
64
const result = schemaToOpenAPI ( schema ) as OpenAPIV3 . SchemaObject ;
75
65
76
- // Check that the result has the correct type
77
66
assert . equal ( result . type , 'number' ) ;
78
67
} ) ;
79
68
80
- // Test string-encoded integer types
81
69
test ( 'string-encoded integer types are properly mapped' , ( ) => {
82
- // Create a schema for a string-encoded integer
83
70
const schema : Schema = {
84
71
type : 'string' ,
85
72
format : 'integer' ,
@@ -88,13 +75,10 @@ test('string-encoded integer types are properly mapped', () => {
88
75
89
76
const result = schemaToOpenAPI ( schema ) as OpenAPIV3 . SchemaObject ;
90
77
91
- // Check that the result has the correct type
92
78
assert . equal ( result . type , 'integer' ) ;
93
79
} ) ;
94
80
95
- // Test BigInt types
96
81
test ( 'BigInt types are properly mapped' , ( ) => {
97
- // Create a schema for a BigInt
98
82
const schema : Schema = {
99
83
type : 'string' ,
100
84
format : 'number' ,
@@ -103,14 +87,11 @@ test('BigInt types are properly mapped', () => {
103
87
104
88
const result = schemaToOpenAPI ( schema ) as OpenAPIV3 . SchemaObject ;
105
89
106
- // Check that the result has the correct type and format
107
90
assert . equal ( result . type , 'integer' ) ;
108
91
assert . equal ( result . format , 'int64' ) ;
109
92
} ) ;
110
93
111
- // Test BigInt types with constraints
112
94
test ( 'BigInt types with constraints are properly mapped' , ( ) => {
113
- // Create a schema for a BigInt with constraints
114
95
const schema : Schema = {
115
96
type : 'string' ,
116
97
format : 'number' ,
@@ -121,7 +102,6 @@ test('BigInt types with constraints are properly mapped', () => {
121
102
122
103
const result = schemaToOpenAPI ( schema ) as OpenAPIV3 . SchemaObject ;
123
104
124
- // Check that the result has the correct type, format, and constraints
125
105
assert . equal ( result . type , 'integer' ) ;
126
106
assert . equal ( result . format , 'int64' ) ;
127
107
assert . equal ( result . minimum , 0 ) ;
0 commit comments