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

fix: schema extraction object type name #6014

Merged
merged 1 commit into from Mar 18, 2024

Conversation

sgulseth
Copy link
Member

Description

For some objects(I belive it's nested objects, but yet to verify) we sometimes generate object schema types with name set to object. This PR removes the _type if it's object, as it's better to miss data than to be wrong.

One example from the tests are Homestead, the compiled schema type look like:

{
  jsonType: 'object',
  type: { name: 'object', title: 'Object', type: null, jsonType: 'object' },
  name: 'object',
  title: 'Homestead',
  fields: [
    {
      name: 'lat',
      group: undefined,
      fieldset: undefined,
      type: [Object]
    },
    {
      name: 'lon',
      group: undefined,
      fieldset: undefined,
      type: [Object]
    }
  ],
  options: {},
  orderings: [
    { name: 'lat', i18n: [Object], title: 'Lat', by: [Array] },
    { name: 'lon', i18n: [Object], title: 'Lon', by: [Array] }
  ],
  fieldsets: [Getter],
  groups: [Getter],
  preview: [Getter]
}

However the field definition is:

{
  name: 'homestead',
  title: 'Homestead',
  type: 'object',
  fields: [
    {
      name: 'lat',
      title: 'Latitude',
      type: 'number',
      required: true,
    },
    {
      name: 'lon',
      title: 'Longitude',
      type: 'number',
      required: true,
    },
  ],
},

What to review

Testing

Notes for release

N/A - no notes needed

@sgulseth sgulseth requested a review from a team as a code owner March 15, 2024 13:57
@sgulseth sgulseth requested review from jtpetty and bjoerge and removed request for a team and jtpetty March 15, 2024 13:57
Copy link

vercel bot commented Mar 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Mar 15, 2024 1:59pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 15, 2024 1:59pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Mar 15, 2024 1:59pm

Copy link
Contributor

No changes to documentation

Copy link
Contributor

Component Testing Report Updated Mar 15, 2024 2:06 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 32s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 12s 3 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 12s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 31s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 0s 15 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 0s 18 0 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 11s 6 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ❌ Failed (Inspect) 24s 8 0 1

Copy link
Member

@bjoerge bjoerge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct to me. Values of schema types with {type: 'object'} should not get {_type: 'object'} (as it's implied). Good catch!

@sgulseth sgulseth added this pull request to the merge queue Mar 18, 2024
Merged via the queue into next with commit dcd5537 Mar 18, 2024
33 of 35 checks passed
@sgulseth sgulseth deleted the fix/schema-extraction-object-type branch March 18, 2024 09:31
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

Successfully merging this pull request may close these issues.

None yet

2 participants