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
  • #1672
Closed
Open
Issue created Dec 14, 2018 by Administrator@rootContributor

[BUG][MYSQL-SCHEMA] howto handle nested objects in schema generation?

Created by: el2ro

Description

When generating DB schema out of OpenAPI spec how should be nested data structures be handled?

Currently it is working so that nested object will create a new table with fields in nested structure. Nested parameter in parent table is set as TEXT. This does not feel like right?

I am not sure if this is a bug, but I am looking info how this should be really handled in nested object case. Background: I am trying to make Postgresql-schema generator and this thing came up, this also applies to mysql-schema generator.

Somehow it feels that it should set nested object as JSON type to main table and not to generate additional table at all.

openapi-generator version

3.3.4 or 4.x.x

Using 3.xx open api yaml spec

OpenAPI declaration file content or url

Full test.yaml https://gist.github.com/el2ro/7d6a3007389429b906b4a49878621dc7 Only important part of it:

components:
  schemas:
    Test:
      title: test
      type: object
      description: Test
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        description:
          type: string
        settings:
          type: object
          description: Nested object inside an object
          properties:
            startValue:
              type: object
            endValue:
              type: object
            someValue:
              type: object
CREATE TABLE IF NOT EXISTS `Test` (
  `id` TEXT DEFAULT NULL,
  `name` TEXT DEFAULT NULL,
  `description` TEXT DEFAULT NULL,
  `settings` TEXT DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Test';

CREATE TABLE IF NOT EXISTS `Test_settings` (
  `startValue` JSON DEFAULT NULL,
  `endValue` JSON DEFAULT NULL,
  `someValue` JSON DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Nested object inside an object';

(for JSON code), so it becomes more readable. If it is longer than about ten lines, please create a Gist (https://gist.github.com) or upload it somewhere else and link it here. -->

Command line used for generation
openapi-generator generate \
   -i src/test.yaml \
   -g mysql-schema \
   -o generated/
Related issues/PRs
Suggest a fix
Assignee
Assign to
Time tracking