protected void registerResponse ( Swagger swagger , Operation operation , Return aReturn ) { Response response = new Response ( ) ; response . setDescription ( translate ( aReturn . descriptionKey ( ) , aReturn . description ( ) ) ) ; Class < ? > resultType = aReturn . onResult ( ) ; if ( Exception . class . isAssignableFrom ( resultType ) ) { Property errorProperty = registerErrorModel ( swagger ) ; response . setSchema ( errorProperty ) ; } else if ( Void . class != resultType ) { // Return type if ( resultType . isArray ( ) ) { // ARRAY[] Class < ? > componentClass = resultType . getComponentType ( ) ; ArrayProperty arrayProperty = new ArrayProperty ( ) ; Property componentProperty = getSwaggerProperty ( swagger , componentClass ) ; arrayProperty . setItems ( componentProperty ) ; response . setSchema ( arrayProperty ) ; } else { // Object Property returnProperty = getSwaggerProperty ( swagger , resultType ) ; response . setSchema ( returnProperty ) ; } } for ( Class < ? extends ReturnHeader > returnHeader : aReturn . headers ( ) ) { Tag headerTag = getModelTag ( returnHeader ) ; ReturnHeader header = ClassUtil . newInstance ( returnHeader ) ; Property property = getSwaggerProperty ( swagger , header . getHeaderType ( ) ) ; if ( property instanceof ArrayProperty ) { // FIXME swagger-core has incomplete response header specification methods :( ArrayProperty arrayProperty = ( ArrayProperty ) property ; } property . setName ( headerTag . getName ( ) ) ; property . setDescription ( headerTag . getDescription ( ) ) ; response . addHeader ( property . getName ( ) , property ) ; } operation . response ( aReturn . code ( ) , response ) ; }
Registers a declared response for the operation .