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

required type does not get originalType #1512

Open
ShaunSHamilton opened this issue Aug 7, 2024 · 0 comments
Open

required type does not get originalType #1512

ShaunSHamilton opened this issue Aug 7, 2024 · 0 comments

Comments

@ShaunSHamilton
Copy link

A required type or list type does not get the originalType field.

function getJSONSchemaForPropertyReference(
field: DMMF.Field,
{ schemaId, persistOriginalType }: TransformOptions,
): JSONSchema7 {
const notNullable = field.isRequired || field.isList
assertFieldTypeIsString(field.type)
const typeRef = `${DEFINITIONS_ROOT}${field.type}`
const ref = { $ref: schemaId ? `${schemaId}${typeRef}` : typeRef }
return notNullable
? ref
: {
anyOf: [ref, { type: 'null' }],
...(persistOriginalType && {
originalType: field.type,
}),
}
}

I found this odd, because I cannot see a reason my Config type should not have a "originalType": "Config" property in the schema:

model A {
  config Config
}

type Config {
  anything String
}
{
  "definitions": {
    "A": {
      "type": "object",
      "properties": {
        "config": {
          "$ref": "#/definitions/Config"
        }
      }
    },
    "Config": {
      "type": "object",
      "properties": {
        "anything": {
          "type": "string",
          "originalType": "String"
        }
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant