valentinpalkovic / prisma-json-schema-generator

A generator for Prisma 2 to generate a valid JSON Schema (v7)
MIT License
276 stars 31 forks source link

Fix anyOf format #1474

Closed navalex closed 1 month ago

navalex commented 2 months ago

Hey,

I noticed some warnings from my Fastify on some Date fields from my Prisma generated schemas. After some investigation, I found that when we have a properties with several possible types (with the anyOf key), for example a nullable Date, the generator do it wrong, because it put the "format": "date-time" outside the anyOf key, which is not correct.

I made 2 tiny changes to remove the format key of the property root if there is a anyOf key, and add the format inside the anyOf if there's one, except for the null type.

valentinpalkovic commented 2 months ago

Hi @navalex

Thank you very much for your contribution!

Could you please add some test cases?

navalex commented 2 months ago

Hi @valentinpalkovic, I'll try to that in the next week, keep you in touch! ;)

navalex commented 2 months ago

Never mind, I just added a simple test with a DateTime? property to a simple datamodel, is it good for you or you want deeper test ?

navalex commented 2 months ago

I finished to fix the tests, it should pass the CI now

github-actions[bot] commented 1 month ago

:tada: This PR is included in version 5.1.5 :tada:

The release is available on:

Your semantic-release bot :package::rocket: