swagger123
2 years agoNew Member
Reference error responses in OAS3
Hi, I'm trying to figure out the correct way of referencing error responses in openapi 3.
It seems OK to reference the '404' response object this way. At least the swagger editor do not complain.
However, I get build error not finding that model when generating kotlin client code with the Swagger editor client generator.
https://editor-next.swagger.io/
openapi: 3.0.3
info:
title: Foo bar API
version: 1.0.0
paths:
/foo/{bar}:
get:
summary: Get bar.
description: Returns bar.
parameters:
- in: path
name: bar
schema:
$ref: '#/components/schemas/BarId'
required: true
description: The bar.
responses:
'200':
description: Bar found.
content:
application/json:
schema:
$ref: '#/components/schemas/BarId'
'404':
description: Bar is missing
content:
application/json:
schema:
$ref: '#/components/responses/FooError'
components:
schemas:
BarId:
description: "Bar id"
type: string
example: 123
responses:
FooError:
description: Error
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Something went wrong.