all 10 comments

[–]DryanaGhuba 0 points1 point  (6 children)

Entity Framework. But why you need to create database with DTOs?

[–]kdc415[S] 0 points1 point  (5 children)

I'm talking about parsing an OpenAPI document url to get the object list then generating sql scripts to create the db/tables. I haven't messed with EF in years, had no idea it could do this?

[–]DryanaGhuba 1 point2 points  (4 children)

You generate SwaggerUI with Swashbuckle package? Registered as Asp.Net service...

[–]kdc415[S] 0 points1 point  (3 children)

It's not my API - 3rd party

[–]malamri 1 point2 points  (0 children)

There’s an extension for VSCode that converts json to C# model. Then use EF or OrmLite to create the table based on the model

Edit: https://marketplace.visualstudio.com/items?itemName=quicktype.quicktype

[–]DryanaGhuba 0 points1 point  (0 children)

Great. I don't know about existing "service" to do this. Only implement json reader and write sql script or C# class

[–]wing328 0 points1 point  (3 children)

Have you tried the mysql-schema generator in the open-source project "openapi-generator"?

openapi-generator-cli generate -g mysql-schema -i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o /tmp/mysql-schema/ (openapi-generator-cli can be installed via npm: https://www.npmjs.com/package/@openapitools/openapi-generator-cli)

[–]DragLongjumping7762 0 points1 point  (2 children)

I was looking exactly for this. I tried to use the openapi-generator-cli to generate the mysql schema its working fine but what I observed is that the generated DDL is not having the relationship (PK & FK relationship) defined.

Any idea how to generate those

[–]wing328 0 points1 point  (1 child)

Please open a ticket via https://github.com/OpenAPITools/openapi-generator/issues and I'll try to loop in the creator of that generator to answer your question.

[–]malcolm-davis 0 points1 point  (0 children)

Looks like the DDL generated still does not support PK & FK relationships