0

I'm trying to upgrade Swagger from 1.2 to 2.0 and I'm having issues getting the Operation type. In 1.2 the Operation Object included the Data Type Fields in order to describe the return value of the operation. But it doesn't look like this is the case for 2.0.

Is there a simple way to access an Operation Object's type?

nastassiar
  • 1,545
  • 2
  • 24
  • 43
  • You're migrating it manually? Using a specific library? – Ron Apr 16 '15 at 17:46
  • Yes upgrading manually. I created a bunch of OperationFilters I still want to use but I'm having issues upgrading all of the objects. – nastassiar Apr 16 '15 at 17:50
  • Have you read https://github.com/domaindrivendev/Swashbuckle#transitioning-to-swashbuckle-50? – Ron Apr 16 '15 at 17:56
  • Yes and the documentation for 2.0 and 1.2 but I couldn't find a way to get the operation type in 2.0 since the Operation Object no longer has the Data Type Fields – nastassiar Apr 16 '15 at 18:02
  • I don't know how it works in Swashbuckle specifically but in Swagger 2.0, the operation itself doesn't have the response type directly in it but all the responses must be described under a Responses object from the operation. Perhaps that would push you in the right direction. – Ron Apr 16 '15 at 18:03
  • Thanks, you are right the type has moved to the response! – nastassiar Apr 16 '15 at 19:02
  • Glad to hear it worked out. Would be great if you supplied a full answer below for the benefit of others who may encounter something similar. – Ron Apr 16 '15 at 19:05

1 Answers1

1

https://github.com/swagger-api/swagger-spec/wiki/Swagger-1.2-to-2.0-Migration-Guide

"The return value of an operation was moved to to the responses section, to be combined with the appropriate http status code (most likely in the 2XX range). As a result, the responses is now mandatory and must have at least one response described by it."

So the type can be accessed from the response.schema.type or also response.schema.@ref

nastassiar
  • 1,545
  • 2
  • 24
  • 43