Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL Schema Generator #1055

Merged
merged 5 commits into from
Oct 1, 2018
Merged

Conversation

ybelenko
Copy link
Contributor

@ybelenko ybelenko commented Sep 18, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.3.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

I'm happy to finally represent first version of MySQL schema generator. 🎆
Current version is beta, but I need feedback from community asap.
Related discussion about data mapping #955

How to refresh samples

$ ./bin/mysql-schema-server-petstore.sh

What else I gonna do

  • Add defaultDatabaseName cli option
  • Reconsider every mustache variable, to avoid spelling overhead (eg. mysqlSchemaColumnDataTypeDefinition)
  • Fix DEFAULT statements generation
  • Add cli option jsonDataTypeEnabled which true by default. When it's disabled, all object and array data maps to TEXT data type
  • Add test spec file which covers all edge cases of current generator

cc @OpenAPITools/generator-core-team

@wing328 If you think it's appropriate to notify somebody beside core team members to this thread, please do that in a next comment

@ybelenko
Copy link
Contributor Author

Now we faced TEXT column issue. It doesn't support DEFAULT definition.
It means that model property without minLength and maxLength like that:

Animal:
  type: object
  discriminator: className
  required:
    - className
  properties:
    className:
      type: string
    color:
      type: string
      default: 'red'

will produce:

CREATE TABLE IF NOT EXISTS `Animal` (
  `className` TEXT NOT NULL,
  `color` TEXT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

VARCHAR(255) could solve this issue, but I agree with @jimschubert that TEXT as default column type covers more cases.

@ybelenko ybelenko force-pushed the mysql_schema_generator branch 4 times, most recently from c3911e0 to e827910 Compare September 22, 2018 07:29
@ybelenko ybelenko removed the WIP Work in Progress label Sep 22, 2018
@ybelenko ybelenko changed the title [WIP] MySQL Schema Generator #955 MySQL Schema Generator #955 Sep 22, 2018
@wing328 wing328 added the Schema: MySQL Generation of a MySQL Schema label Sep 25, 2018
@wing328
Copy link
Member

wing328 commented Sep 25, 2018

About the CI failures, it seems like some Java docstrings have minor issues:

Generating C:\Users\User\Code\openapi-generator\modules\openapi-generator\target\site\apidocs\help-doc.html...
2 warnings
[WARNING] Javadoc Warnings
[WARNING] C:\Users\User\Code\openapi-generator\modules\openapi-generator\src\main\java\org\openapitools\codegen\languages\MysqlSchemaServerCodegen.java:834: warning: no description for @return
[WARNING] * @return
[WARNING] ^
[WARNING] C:\Users\User\Code\openapi-generator\modules\openapi-generator\src\main\java\org\openapitools\codegen\languages\MysqlSchemaServerCodegen.java:1003: warning: no description for @return
[WARNING] * @return
[WARNING] ^

To repeat that locally, please try mvn javadoc:javadoc

@wing328 wing328 merged commit e4b5f50 into OpenAPITools:master Oct 1, 2018
@wing328 wing328 changed the title MySQL Schema Generator #955 MySQL Schema Generator Oct 1, 2018
@wing328
Copy link
Member

wing328 commented Oct 2, 2018

@ybelenko thanks again for the new generator, which is included in the v3.3.0 minor release: https://twitter.com/oas_generator/status/1046941449609068544

@ybelenko ybelenko deleted the mysql_schema_generator branch November 17, 2018 05:05
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
* [Mysql Schema] Add new generator

* [Mysql Schema] Fix default definition

* [Mysql Schema] Add defaultDatabaseName option

* [Mysql Schema] Add jsonDataTypeEnabled option

* [Mysql Schema] Add samples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants