You can’t – the spec doesn’t support global responses. You can define a reusable response, but would still have to reference it from the different operations.
From: <[email protected]> on behalf of "[email protected]" <[email protected]> Reply-To: "[email protected]" <[email protected]> Date: Tuesday, 18 July 2017 at 20:11 To: Swagger <[email protected]> Subject: How to set the 401 "Unauthorized" response globally? Hi All, I am new to swagger & am trying out the features ; thus please excuse my question if it's already a documented one. I tried looking for information but could not find any... How to set the 401 "Unauthorized" response globally? That is, without having to refer in several operations? swagger: '2.0' info: title: xxxxxxx description: >- xxxxxxxx version: 1.0.0 contact: name: xxxx email: xxxx license: name: Apache 2.0 url: 'http://www.apache.org/licenses/LICENSE-2.0.html' host: dev.goscore.com.br schemes: - https basePath: /api/v1 produces: - application/json #Algumas APIs usam mais de uma chave de segurança, digamos, API Key e ID da API. Para especificar que as chaves são usadas em conjunto (como em AND lógico), liste-as no mesmo item na matriz de segurança: securityDefinitions: apiKey: #Para definir a segurança baseada na chave da API: type: apiKey in: header name: X-API-KEY basicAuth: #Para aplicar a autenticação básica para toda a API: type: basic appId: type: apiKey in: header name: X-APP-ID security: - apiKey: [] appId: [] paths: /products: post: tags: - Products summary: Armazena um recurso recém-criado description: Cria um produto e o armazena no sistema (ProductsController) operationId: ProductsController@store produces: - application/json responses: '200': description: Ok schema: $ref: '#/definitions/Product' get: tags: - Products summary: Lista todas os produtos cadastrados no sistema. operationId: ProductsController@index description: Retorna uma lista com todas os produtos de disponibilidade HORIZONTAL, VERTICAL e UAU cadastrados no sistema (ProductsController). responses: '200': description: Ok schema: type: array items: $ref: '#/definitions/Product' default: description: Ops! Ocorreu um erro na sua solicitação. Desculpe-nos o transtorno. Iremos corrigir para que isto não volte a acontecer e você tenha a melhor experiência com o Go Score! schema: $ref: '#/definitions/Error' Error: type: object properties: code: type: integer format: int32 message: type: string fields: type: string -- You received this message because you are subscribed to the Google Groups "Swagger" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Swagger" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
