openapi-generator/samples/schema/petstore/mysql
William Cheng 774013c7e1
Better OpenAPI spec v3 support: allOf, anyOf, oneOf (#1360)
* add oneOf support to Ruby

* add anyOf support to ruby client

* add discriminator support to ruby client

* fix typo

* update samples, fix NPE

* better format in ruby generator

* fix test cases, disable mapping test

* fix update script, update samples

* add test, fix mapping

* update exit code

* reenabled discriminator test

* remove duplicated properties

* add test for duplicated properties

* update samples, add new spec

* fix ruby test cases

* fix hasMore after removing duplicates

* refactor method, comment out haskell client test

* fix hasMore and update samples

* fix parent detection

* fix discriminator check

* [haskell-http-client] need to use {{vars}}{{required}} instead of {{requiredVars}}

* remove deprecated methods in default codegen (#1031)

* regenerate samples

* remove commented code
2018-12-07 00:30:20 +08:00
..
.openapi-generator update petstore samples 2018-11-08 18:32:48 +08:00
.openapi-generator-ignore MySQL Schema Generator #955 (#1055) 2018-10-01 15:59:18 +08:00
mysql_schema.sql Better OpenAPI spec v3 support: allOf, anyOf, oneOf (#1360) 2018-12-07 00:30:20 +08:00
README.md MySQL Schema Generator #955 (#1055) 2018-10-01 15:59:18 +08:00

MySQL Schema Codegen

Main goal of this generator is to provide database structure file almost identical you usually generate with:

  • PHPMyAdmin (Export structure only, SQL syntax)
  • Adminer
  • mysqldump function

MySQL documentation

Requirements

  • MySQL Server ^5.7.8 (JSON column type added)

Openapi Data Type to MySQL Data Type mapping

Openapi Data Type Openapi Data Format Dependent properties MySQL Data Types Default MySQL Data Type
integer int32 minimum / maximum / minimumExclusive / maximumExclusive TINYINT / SMALLINT / MEDIUMINT/ INT / BIGINT INT
integer int64 minimum / maximum / minimumExclusive / maximumExclusive TINYINT / SMALLINT / MEDIUMINT / INT / BIGINT BIGINT
boolean TINYINT TINYINT
number float DECIMAL DECIMAL
number double DECIMAL DECIMAL
string minLength / maxLength CHAR / VARCHAR / TEXT / MEDIUMTEXT / LONGTEXT TEXT
string byte TEXT TEXT
string binary MEDIUMBLOB MEDIUMBLOB
file MEDIUMBLOB MEDIUMBLOB
string date DATE DATE
string date-time DATETIME DATETIME
string enum ENUM ENUM
array JSON JSON
object JSON JSON
\Model\User (referenced definition) TEXT TEXT

How to use

Produced file(mysql_schema.sql) contains every table definition. Current implementation doesn't drop or modify existed tables, if you want rewrite whole schema make sure they're not presented.

PHPMyAdmin

  1. Choose Import tab from the home screen
  2. In section File to import click to Choose File and find generated mysql_schema.sql
  3. Make sure Format selector set to SQL
  4. Push Go button

Adminer

  1. Click Import link in left sidebar
  2. In File upload fieldset click to Choose Files and find generated mysql_schema.sql
  3. Push Execute button