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

[BUG][POSTGRESQL] JSON datatype not recognised for referenced types #20358

Open
5 of 6 tasks
geekysquirrel opened this issue Dec 20, 2024 · 0 comments
Open
5 of 6 tasks

Comments

@geekysquirrel
Copy link

geekysquirrel commented Dec 20, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

First of all @iri thanks so much for adding a postgres schema generator!

Here's my issue:
When trying to generate a database schema using postgresql-schema, the datatype for referenced ($ref) schemas is not recognised correctly.

openapi-generator version

:latest docker image as of today.

OpenAPI declaration file content or url
"geotag": {
    "$ref":"#/components/schemas/geotag"
},

Full file here.

Generation Details

Generating using a Makefile that starts the generator in a docker container.

Steps to reproduce

In the example below I'm showing two properties, geotag and exif both of which should be JSON dataypes. exif is defined in place and correctly assigned the JSON datatype whereas geotag uses a $ref to the schema further down in the screenshot but ends up being classed as TEXT.

image

image

Looking at the log, it seems like because the type is detected to be the name of the referenced model it falls back to the default which is TEXT:

image

Related issues/PRs

Couldn't find any.

Suggest a fix

Digging through the generator code it looked like it required a type property but of course it being a $ref that's not allowed and called out by the validator:

image

I also tried to use the mysql-schema generator which suffers from the same issue.

The suggested fix would be I guess to check referenced schemas for their datatype instead of only relying on a type property in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant