yii2-openapi icon indicating copy to clipboard operation
yii2-openapi copied to clipboard

For ENUM colums, existing column gets an update which removes the "string type"

Open SOHELAHMED7 opened this issue 3 years ago • 1 comments

https://github.com/cebe/yii2-openapi/issues/100#issuecomment-1135982903

SOHELAHMED7 avatar Sep 30 '22 11:09 SOHELAHMED7

this should already be fixed by #103

cebe avatar Sep 30 '22 15:09 cebe

Enum behaviour will likely to be changed:

Currently we provide x-db-type for enum fields/columns.

Enum is not a real data type in Pgsql

Ideally we provide x-db-type when we have more than one way to store same data. E.g. time: we can store it as timestamp or datetime string.

For enum no matter what database we use, we store it as corresponding enum way. There is no more than one way to store enum values in DB.

Changes I will implement for enum if there is a enum field in yml:

  • if we provide x-db-type an error will be thrown that setting x-db-type has no effect and should be avoided. For enum fields yii2-openapi lib will automatically create enum column/type depending on the DB type

Incorrect:

lang:
          type: string
          x-db-type: enum
          enum:
            - ru
            - eng

Correct:

lang:
          type: string
          enum:
            - ru
            - eng

@cebe please comment if there is anything wrong with above approach.

SOHELAHMED7 avatar Nov 24 '22 07:11 SOHELAHMED7

@SOHELAHMED7 I'm gernerally fine with that solution.

cebe avatar Dec 07 '22 08:12 cebe

This issue can be closed.

SOHELAHMED7 avatar Dec 29 '22 12:12 SOHELAHMED7