carlansley / swagger2

Loading, parsing and validating requests to HTTP services based on Swagger v2.0 documents
MIT License
25 stars 17 forks source link

Check if default response is defined when matching unknown response #8

Closed shaxbee closed 7 years ago

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.3%) to 99.69% when pulling a16b16867fc6f07de60fa616e5d74bd31ed8ca6b on shaxbee:no-default-response into 1e1ec57bff51a47bdc42aa8692352da7589bca37 on carlansley:master.

shaxbee commented 7 years ago

To be honest your solution seems to be more reasonable :-)

On Wed, Nov 30, 2016, 11:00 PM Carl Ansley notifications@github.com wrote:

@carlansley commented on this pull request.

In src/validate.ts https://github.com/carlansley/swagger2/pull/8:

@@ -178,6 +178,12 @@ export function response(compiledPath: CompiledPath | undefined, if (response === undefined) { response = operation.responses['default']; }

  • if (response === undefined) {

Actually on second reading there's really no specified behavior for this situation. I'll merge this PR but may move the error check to the validate function. Thanks!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/carlansley/swagger2/pull/8, or mute the thread https://github.com/notifications/unsubscribe-auth/AE_mfZPZpjmkWDy0Pc8rdAR49yc3vGlNks5rDY-NgaJpZM4K_9zJ .

carlansley commented 7 years ago

:) it may well be but in the absence of clear spec-defined behavior I think an error is a logical approach for now. swagger2-koa will respond with a 500 which I think is ok; the spec does say that all known responses (good & errors) should be defined.

I'm going to raise an issue on OA/OpenAPI-Specification about this.