Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3534
Closed
Open
Issue created Aug 02, 2019 by Administrator@rootContributor

[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.

Assignee
Assign to
Time tracking