@@ -2,20 +2,20 @@ import type {
22 OpenAPI as OpenAPI_3_1 ,
33 OpenAPISecurityRequirement ,
44 OpenAPITag ,
5- } from " ./Core.types.ts" ;
6- import { createEndpointBuilder } from " ./EndpointBuilder.ts" ;
7- import { createEndpointPath , type EndpointPath } from " ./EndpointPath.ts" ;
8- import type { AllowedLicenses } from " ./Licenses.types.ts" ;
5+ } from ' ./Core.types.ts' ;
6+ import { createEndpointBuilder } from ' ./EndpointBuilder.ts' ;
7+ import { createEndpointPath , type EndpointPath } from ' ./EndpointPath.ts' ;
8+ import type { AllowedLicenses } from ' ./Licenses.types.ts' ;
99
1010class OpenAPI {
1111 private raw : OpenAPI_3_1 ;
1212
1313 constructor ( ) {
1414 this . raw = {
15- openapi : " 3.1.0" ,
15+ openapi : ' 3.1.0' ,
1616 info : {
17- title : " OpenAPI 3.1.0" ,
18- version : " 1.0.0" ,
17+ title : ' OpenAPI 3.1.0' ,
18+ version : ' 1.0.0' ,
1919 } ,
2020 } ;
2121 }
@@ -63,19 +63,19 @@ class OpenAPI {
6363 }
6464
6565 setLicenseName ( name : string ) : this {
66- this . raw . info . license = this . raw . info . license || { name : "" } ;
66+ this . raw . info . license = this . raw . info . license || { name : '' } ;
6767 this . raw . info . license . name = name ;
6868 return this ;
6969 }
7070
7171 setLicenseUrl ( url : string ) : this {
72- this . raw . info . license = this . raw . info . license || { name : "" } ;
72+ this . raw . info . license = this . raw . info . license || { name : '' } ;
7373 this . raw . info . license . url = url ;
7474 return this ;
7575 }
7676
7777 setLicenseIdentifier ( identifier : AllowedLicenses ) : this {
78- this . raw . info . license = this . raw . info . license || { name : "" } ;
78+ this . raw . info . license = this . raw . info . license || { name : '' } ;
7979 this . raw . info . license . identifier = identifier ;
8080 return this ;
8181 }
@@ -104,7 +104,7 @@ class OpenAPI {
104104 }
105105
106106 setSecurity ( scheme : {
107- type : " apiKey" | " http" | " oauth2" | " openIdConnect" ;
107+ type : ' apiKey' | ' http' | ' oauth2' | ' openIdConnect' ;
108108 name : string ;
109109 scopes ?: string [ ] ;
110110 } ) : this {
@@ -153,83 +153,83 @@ class OpenAPI {
153153 }
154154}
155155
156- export { OpenAPI } ;
157-
158- const openAPI = new OpenAPI ( ) ;
159-
160- openAPI
161- . setTitle ( " My API" )
162- . setVersion ( " 1.0.0" )
163- . setDescription ( " This is my API" )
164- . setTermsOfService ( " https://example.com/terms" )
165- . setContactName ( " John Doe" )
166- . setContactUrl ( " https://example.com/contact" )
167- . setContactEmail ( " john@gmail.com" )
168- . addEndpointPath (
169- createEndpointPath ( " /users/{userId}" )
170- . setSummary ( " Process group of users" )
171- . setDescription ( " This endpoint processes a group of users" )
172- . setParameter ( " userId" , " path" , true , " The ID of the user" )
173- . addEndpoint (
174- createEndpointBuilder ( " get" )
175- . setOperationId ( " getUser" )
176- . setSummary ( " Get user by ID" )
177- . setDescription ( " This endpoint retrieves a user by ID" )
178- . setTags ( [ " User" ] )
179- . setExternalDocs ( " https://example.com/docs" , " API Documentation" )
180- . setSecurity ( { apiKey : [ ] } )
181- . setParameter ( " userId" , " path" , true , " The ID of the user" )
182- . setRequestBody (
183- {
184- " application/json" : {
185- schema : {
186- type : " object" ,
187- properties : {
188- name : { type : " string" } ,
189- age : { type : " integer" } ,
190- } ,
191- } ,
192- } ,
193- } ,
194- true ,
195- )
196- . setResponses ( {
197- 200 : {
198- description : " User retrieved successfully" ,
199- content : {
200- " application/json" : {
201- schema : {
202- type : " object" ,
203- properties : {
204- id : { type : " string" } ,
205- name : { type : " string" } ,
206- age : { type : " integer" } ,
207- } ,
208- } ,
209- } ,
210- } ,
211- } ,
212- 404 : {
213- description : " User not found" ,
214- } ,
215- } ) ,
216- )
217- . addEndpoint (
218- createEndpointBuilder ( " delete" )
219- . setOperationId ( " deleteUser" )
220- . setSummary ( " Delete user by ID" )
221- . setDescription ( " This endpoint deletes a user by ID" )
222- . setTags ( [ " User" ] )
223- . setExternalDocs ( " https://example.com/docs" , " API Documentation" )
224- . setSecurity ( { apiKey : [ ] } )
225- . setParameter ( " userId" , " path" , true , " The ID of the user" )
226- . setResponses ( {
227- 204 : {
228- description : " User deleted successfully" ,
229- } ,
230- 404 : {
231- description : " User not found" ,
232- } ,
233- } ) ,
234- ) ,
235- ) ;
156+ export { OpenAPI , createEndpointPath , createEndpointBuilder } ;
157+
158+ // const openAPI = new OpenAPI();
159+
160+ // openAPI
161+ // .setTitle(' My API' )
162+ // .setVersion(' 1.0.0' )
163+ // .setDescription(' This is my API' )
164+ // .setTermsOfService(' https://example.com/terms' )
165+ // .setContactName(' John Doe' )
166+ // .setContactUrl(' https://example.com/contact' )
167+ // .setContactEmail(' john@gmail.com' )
168+ // .addEndpointPath(
169+ // createEndpointPath(' /users/{userId}' )
170+ // .setSummary(' Process group of users' )
171+ // .setDescription(' This endpoint processes a group of users' )
172+ // .setParameter(' userId', ' path' , true, ' The ID of the user' )
173+ // .addEndpoint(
174+ // createEndpointBuilder(' get' )
175+ // .setOperationId(' getUser' )
176+ // .setSummary(' Get user by ID' )
177+ // .setDescription(' This endpoint retrieves a user by ID' )
178+ // .setTags([' User' ])
179+ // .setExternalDocs(' https://example.com/docs', ' API Documentation' )
180+ // .setSecurity({ apiKey: [] })
181+ // .setParameter(' userId', ' path' , true, ' The ID of the user' )
182+ // .setRequestBody(
183+ // {
184+ // ' application/json' : {
185+ // schema: {
186+ // type: ' object' ,
187+ // properties: {
188+ // name: { type: ' string' },
189+ // age: { type: ' integer' },
190+ // },
191+ // },
192+ // },
193+ // },
194+ // true
195+ // )
196+ // .setResponses({
197+ // 200: {
198+ // description: ' User retrieved successfully' ,
199+ // content: {
200+ // ' application/json' : {
201+ // schema: {
202+ // type: ' object' ,
203+ // properties: {
204+ // id: { type: ' string' },
205+ // name: { type: ' string' },
206+ // age: { type: ' integer' },
207+ // },
208+ // },
209+ // },
210+ // },
211+ // },
212+ // 404: {
213+ // description: ' User not found' ,
214+ // },
215+ // })
216+ // )
217+ // .addEndpoint(
218+ // createEndpointBuilder(' delete' )
219+ // .setOperationId(' deleteUser' )
220+ // .setSummary(' Delete user by ID' )
221+ // .setDescription(' This endpoint deletes a user by ID' )
222+ // .setTags([' User' ])
223+ // .setExternalDocs(' https://example.com/docs', ' API Documentation' )
224+ // .setSecurity({ apiKey: [] })
225+ // .setParameter(' userId', ' path' , true, ' The ID of the user' )
226+ // .setResponses({
227+ // 204: {
228+ // description: ' User deleted successfully' ,
229+ // },
230+ // 404: {
231+ // description: ' User not found' ,
232+ // },
233+ // })
234+ // )
235+ // );
0 commit comments