cebe / yii2-openapi

REST API application generator for Yii2, openapi 3.0 YAML -> Yii2
MIT License
129 stars 23 forks source link

Can not define index on relation id #168

Closed cebe closed 6 months ago

cebe commented 6 months ago
components:
  schemas:
    Webhook:
      x-indexes:
        - 'unique:user_id,name' # references implicit ID
      type: object
      description: example for x-fk-column-name
      properties:
        id:
          type: integer
        name:
          type: string
        user:
          $ref: '#/components/schemas/User' # this will automatically create `user_id` column

results in:

cebe\yii2openapi\lib\exceptions\InvalidDefinitionException: Invalid index definition - property user_id not declared

/app/src/lib/AttributeResolver.php:441
/app/src/lib/AttributeResolver.php:124
/app/src/lib/SchemaToDatabase.php:93
/app/src/generator/ApiGenerator.php:471

I'll submit a failing test case.