feat: Resolver tests for valid and invalid recursive models

This commit is contained in:
Benjamin Nolan (TwoWholeWorms)
2023-01-05 14:07:39 +01:00
committed by Dave Shanley
parent 5f92de63a4
commit e8a954d5ae
5 changed files with 270 additions and 25 deletions

View File

@@ -0,0 +1,93 @@
schemes:
- https
securityDefinitions:
api_token:
type: apiKey
in: header
name: Swagger-Token
definitions:
BaseModel:
description: BaseModel is the top-level definition in this example
type: object
properties:
directChildren:
description: A nested array of direct recursive models.
type: array
items:
$ref: '#/definitions/DirectRecursiveModel'
indirectChildren:
description: A nested array of indirect recursive models.
type: array
items:
$ref: '#/definitions/IndirectRecursiveModelOne'
additionalProperties: false
required:
- directChildren
- indirectChildren
DirectRecursiveModel:
description: DirectRecursiveModel is a nested model which can optionally contain itself.
type: object
properties:
children:
description: A nested array of direct recursive models.
type: array
items:
$ref: '#/definitions/DirectRecursiveModel'
additionalProperties: false
IndirectRecursiveModelOne:
description: IndirectRecursiveModelOne is a nested model which can optionally contain IndirectRecursiveModelTwo.
type: object
properties:
children:
description: A nested array of indirect recursive models.
type: array
items:
$ref: '#/definitions/IndirectRecursiveModelTwo'
additionalProperties: false
IndirectRecursiveModelTwo:
description: IndirectRecursiveModelTwo is a nested model which can optionally contain IndirectRecursiveModelOne.
type: object
properties:
children:
description: A nested array of indirect recursive models.
type: array
items:
$ref: '#/definitions/IndirectRecursiveModelOne'
additionalProperties: false
security:
- api_token: []
produces:
- application/json
paths:
/baseModels:
post:
parameters:
- in: body
name: BaseModel
description: ''
required: true
schema:
$ref: '#/definitions/BaseModel'
responses:
'201':
schema:
$ref: '#/definitions/BaseModel'
description: Resource
'400':
description: Schema mismatch
'404':
description: Resource does not exist
'422':
description: Unprocessable
operationId: createBaseModel
description: Create BaseModel allows you to create a new BaseModel
summary: Create BaseModel
consumes:
- application/json
host: api.app.example.com
info:
title: Valid Recursive Definition Example
version: '1.0'
description: This example contains a recursive model definition which is valid because DirectRecursiveModel's "children" property is optional.
swagger: '2.0'
basePath: /