-
Notifications
You must be signed in to change notification settings - Fork 22
Bug: allOf with multiple $refs #175
Description
PROBLEM
So that the description of the schema.yaml is complete, I would also like to show the related models (which are also returned).
This works for the description.
But unfortunately I can't generate any code afterwards.
GIVEN
openapi: 3.0.3
info:
title: 'Proxy-Service'
version: 1.0.0
components:
responses:
AccountExpanded:
description: 'Returns one account by ID with additional information.'
content:
application/vnd.api+json:
schema:
type: object
required:
- status
- Account
properties:
status:
type: string
enum:
- valid
- invalid
Account:
allOf:
- $ref: '#/components/schemas/Account'
- type: object
properties:
invoiceContact:
$ref: "#/components/schemas/Contact"
paymentMethod:
$ref: "#/components/schemas/PaymentMethod"
errors:
type: object
description: only exists if status = invalid
schemas:
Account:
description: Account
type: object
required:
- id
- name
properties:
id:
type: integer
readOnly: true
name:
description: account name
type: string
maxLength: 128
paymentMethodName:
type: string
Contact:
description: Contact
type: object
required:
- id
- account
properties:
id:
type: integer
readOnly: true
account:
$ref: '#/components/schemas/Account'
active:
type: boolean
default: false
nickname:
type: string
PaymentMethod:
type: object
description: PaymentMethod
x-indexes:
- 'unique:name'
required:
- id
- name
properties:
id:
type: integer
readOnly: true
name:
type: string
example: Bank transfer within 14 days
maxLength: 150
x-faker: false
paths:
'/account/{id}':
parameters:
- name: Id
in: path
description: ID of Account
required: true
schema:
type: integer
get:
operationId: getAccount
summary: Account information
responses:
'200':
$ref: '#/components/responses/AccountExpanded'
'404':
description: Account with id = "\<account_id\>" was not found.
EXECUTE
./yii gii/api
GENERATION BUG
Exception 'Error' with message 'Call to undefined method cebe\openapi\spec\Schema::getJsonReference()'
in /app/vendor/cebe/yii2-openapi/src/lib/openapi/ResponseSchema.php:52
Stack trace:
#0 /app/vendor/cebe/yii2-openapi/src/lib/openapi/ResponseSchema.php(236): cebe\yii2openapi\lib\openapi\ResponseSchema::schemaNameByRef(Object(cebe\openapi\spec\Schema))
#1 /app/vendor/cebe/yii2-openapi/src/lib/openapi/ResponseSchema.php(151): cebe\yii2openapi\lib\openapi\ResponseSchema::guessModelClassFromContent(Object(cebe\openapi\spec\MediaType))
#2 /app/vendor/cebe/yii2-openapi/src/lib/generators/RestActionGenerator.php(90): cebe\yii2openapi\lib\openapi\ResponseSchema::guessModelClass(Object(cebe\openapi\spec\Operation), 'view')
#3 /app/vendor/cebe/yii2-openapi/src/lib/generators/RestActionGenerator.php(74): cebe\yii2openapi\lib\generators\RestActionGenerator->prepareAction('get', Object(cebe\openapi\spec\Operation), Object(cebe\yii2openapi\lib\items\RouteData))
#4 /app/vendor/cebe/yii2-openapi/src/lib/generators/RestActionGenerator.php(56): cebe\yii2openapi\lib\generators\RestActionGenerator->resolvePath('/account/{id}', Object(cebe\openapi\spec\PathItem))
#5 /app/vendor/cebe/yii2-openapi/src/generator/ApiGenerator.php(469): cebe\yii2openapi\lib\generators\RestActionGenerator->generate()
#6 /app/vendor/yiisoft/yii2-gii/src/console/GenerateAction.php(53): cebe\yii2openapi\generator\ApiGenerator->generate()
#7 /app/vendor/yiisoft/yii2-gii/src/console/GenerateAction.php(36): yii\gii\console\GenerateAction->generateCode()
#8 [internal function]: yii\gii\console\GenerateAction->run()
#9 /app/vendor/yiisoft/yii2/base/Action.php(93): call_user_func_array(Array, Array)
#10 /app/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\Action->runWithParams(Array)
#11 /app/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('api', Array)
#12 /app/vendor/yiisoft/yii2/base/Module.php(552): yii\console\Controller->runAction('api', Array)
#13 /app/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('gii/api', Array)
#14 /app/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('gii/api', Array)
#15 /app/vendor/yiisoft/yii2/base/Application.php(384): yii\console\Application->handleRequest(Object(yii\console\Request))
#16 /app/yii(9): yii\base\Application->run()
#17 {main}