[REQ][MySQL] Primary and Foreign Keys
Created by: ybelenko
Is your feature request related to a problem? Please describe.
It would be great to generate tables with primary keys, but current Openapi spec doesn't have an option to clearly mark identifiers. Let's take a look at the example:
# part of /modules/openapi-generator/src/test/resources/2_0/petstore-proto.yaml
Order:
title: Pet Order
description: An order for a pets from the pet store
type: object
properties:
id:
type: integer
format: int64
petId:
type: integer
format: int64
quantity:
type: integer
format: int32
shipDate:
type: string
format: date-time
any experienced developer would say that id is primary key and petId is not(maybe just an index). It just feels so.
Describe the solution you'd like
We can make a guess and add PRIMARY KEY to all properties called id.
Describe alternatives you've considered
Or maybe it's a bad idea from the start and we shouldn't rely on property names. Maybe PRIMARY KEYs should be explicitly specified and with vendor extensions only. Another argument is that PRIMARY KEYs usually followed by AUTO_INCREMENT statement which I don't know how to produce without vendor extension.
Additional context
There was another related discussion in #1672 (closed). I don't know how to produce FOREIGN KEYs either, because it's hard to say which properties are connected identifiers in two models.
I think it's important to hear out all opinions from community before proceed.