yii2-openapi
yii2-openapi copied to clipboard
Bug $ref with x-faker
Initial
schema.yaml
openapi: 3.0.3
# Edit this schema and start your project
# This is sample schema
# To generate code which is based on this schema
# run commands mentioned Development section in README.md file
info:
title: 'Proxy-Service'
description: ""
version: 1.0.0
contact:
name: '...'
email: [email protected]
servers:
- url: 'http://localhost:9937'
description: 'Local Dev API'
security:
- BasicAuth: []
components:
securitySchemes:
BasicAuth:
type: http
scheme: basic
schemas:
Order:
type: object
required:
- id
properties:
id:
type: integer
invoice:
$ref: '#/components/schemas/Invoice'
x-faker: false
Reproduction steps
$ref: AND x-faker on same attribute
Expected Ref-Attribute with NULL in every row.
Result Don't work
UseCase You already have orders, but the corresponding invoices are only made later, by a self-written function, and not by faker.
Update
I tried with
invoice:
allOf:
- $ref: '#/components/schemas/Invoice'
- x-faker: false
Unfortunately that doesn't work either.
The following is then generated for the migration:
$model->invoice = $faker->sentence;
But i need this field empty.
Meanwhile the issue is being fixed, this work-around can be used:
`x-faker: '$faker->optional(0, null)->sentence'`
Edit:
Sorry, it won't work in referenced property at this moment