Closed alastair-todd closed 5 years ago
Actually, the definition of ReferencableEntity is invalid. You have required and properties as elements in the allOf array. This example works as expected:
openapi: '3.0.0'
info:
title: 'Test'
paths:
/foo:
get:
responses:
'200':
content:
application/json:
schema:
$ref: '#components/schemas/ReferencableEntity'
components:
schemas:
UUID:
type: string
Entity:
title: Entity
type: object
description: An abstract object with base properties
required:
- id
- displayName
properties:
id:
$ref: "#/components/schemas/UUID"
displayName:
type: string
minLength: 3
maxLength: 100
ReferencableEntity:
title: ReferencableEntity
description: An abstract object with base properties and a property that is an immutable unique textual reference that can be used in code with impunity
allOf:
- $ref: "#/components/schemas/Entity"
- type: "object"
required:
- uniqueRef
properties:
uniqueRef:
type: string
pattern: ^([a-z][a-z0-9]*)(-[a-z0-9]+)*$
minLength: 3
maxLength: 100
description: lower kebab-case string similar to the displayName
example: roles-read
Take this schema snippet:
generated interface:
Now it is possible to add required at a number of levels to which I profess no knowledge of any differential, but swagger ui is more than happy with the spec: