yii2-openapi
yii2-openapi copied to clipboard
Bug with "format: date-time"
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:
Subscription:
type: object
required:
- id
properties:
id:
type: integer
start:
type: string
format: date-time
end:
type: string
format: date-time
createdAt:
type: string
format: date-time
readOnly: True
updatedAt:
type: string
format: date-time
readOnly: true
Reproduction steps
./yii gii/api ./yii migrate
#again ./yii gii/api
Expected No more migration
Result
<?php
/**
* Table for Subscription
*/
class m240205_140005_change_table_subscriptions extends \yii\db\Migration
{
public function up()
{
$this->alterColumn('{{%subscriptions}}', 'start', $this->timestamp()->null()->defaultValue(null));
$this->alterColumn('{{%subscriptions}}', 'end', $this->timestamp()->null()->defaultValue(null));
$this->alterColumn('{{%subscriptions}}', 'createdAt', $this->timestamp()->null()->defaultValue(null));
$this->alterColumn('{{%subscriptions}}', 'updatedAt', $this->timestamp()->null()->defaultValue(null));
}
public function down()
{
$this->alterColumn('{{%subscriptions}}', 'updatedAt', $this->timestamp()->null()->defaultValue(null));
$this->alterColumn('{{%subscriptions}}', 'createdAt', $this->timestamp()->null()->defaultValue(null));
$this->alterColumn('{{%subscriptions}}', 'end', $this->timestamp()->null()->defaultValue(null));
$this->alterColumn('{{%subscriptions}}', 'start', $this->timestamp()->null()->defaultValue(null));
}
}
I am not able to reproduce this issue.
I attempted to create failing test for PgSQL:
// above attempt yields this migration which is correct and expected
<?php
/**
* Table for Subscription
*/
class m200000_000000_change_table_subscriptions extends \yii\db\Migration
{
public function safeUp()
{
$this->addColumn('{{%subscriptions}}', 'updatedAt2', $this->timestamp()->null()->defaultValue(null));
}
public function safeDown()
{
$this->dropColumn('{{%subscriptions}}', 'updatedAt2');
}
}
Please provide following details:
- which database do you use
- can you give create table statement of your existing (applied migration) table (e.g. subscriptions table)