@@ -15,7 +15,8 @@ class EndpointDoc {
15
15
} , { } )
16
16
this . queryParams = tags . filter ( t => t . title === 'queryParam' )
17
17
. map ( t => QueryParam . parse ( t . description ) )
18
- this . body = tags . find ( t => t . title === 'body' ) ?. description
18
+ this . body = tags . find ( t => t . title === 'body' || t . title == 'request' ) ?. description
19
+ this . response = tags . find ( t => t . title === 'response' ) ?. description
19
20
this . pathParams = this . extractPathParams ( path ) . map ( paramName => `:${ paramName } ` ) . map ( paramName => new PathParam ( paramName ) . merge ( docParms [ paramName ] ) )
20
21
this . produces = tags . filter ( t => t . title === 'produces' ) . map ( t => new ProducesTag ( t . description ) )
21
22
}
@@ -121,6 +122,17 @@ class SwaggerBody {
121
122
}
122
123
}
123
124
125
+ class SwaggerResponse {
126
+
127
+ constructor ( body , contentType = 'application/json' ) {
128
+ if ( body . startsWith ( '{' ) ) {
129
+ this . value = { content : contentType , schema : { type : 'object' , example : body } }
130
+ } else {
131
+ this . value = { content : contentType , schema : { $ref : body } }
132
+ }
133
+ }
134
+ }
135
+
124
136
class SwaggerEndpointPath {
125
137
126
138
constructor ( path , pathParams ) {
@@ -158,4 +170,5 @@ exports.SwaggerPathParam = SwaggerPathParam
158
170
exports . SwaggerEndpointPath = SwaggerEndpointPath
159
171
exports . SwaggerQueryParam = SwaggerQueryParam
160
172
exports . ProducesTag = ProducesTag
161
- exports . SwaggerBody = SwaggerBody
173
+ exports . SwaggerBody = SwaggerBody
174
+ exports . SwaggerResponse = SwaggerResponse
0 commit comments