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

JSON Schema with Dot-Fieldnames #1078

Closed
wants to merge 3 commits into from
Closed

Conversation

kestarumper
Copy link
Member

@kestarumper kestarumper commented Dec 21, 2021

This PR closes #963.

NOTE: This is yet another approach that works, but will probably be changed.

When I was working on the implementation of 2 and 2.5 I encountered some problems which would make the API inconvenient. Instead, I implemented the escape paths. This is more convenient when used with React because you can pass a string to the name prop instead of an array.

Given schema

{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "type": "object",
    "properties": {
      "x": {
        "type": "object",
        "properties": {
          "y.z": {
            "type": "string"
          }
        }
      }
    }
}

we can access it like the following

<AutoField name='x.["y.z"]' />

You can escape the path with brackets like normal.["path.with.dots.in.name"].second.["another.path.with.dots"].0.

@kestarumper kestarumper self-assigned this Dec 21, 2021
@codecov
Copy link

codecov bot commented Dec 21, 2021

Codecov Report

Merging #1078 (a54a7fb) into master (80b6a38) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1078   +/-   ##
=======================================
  Coverage   98.60%   98.60%           
=======================================
  Files         203      203           
  Lines        3217     3225    +8     
  Branches      829      832    +3     
=======================================
+ Hits         3172     3180    +8     
  Partials       45       45           
Impacted Files Coverage Δ
...niforms-bridge-json-schema/src/JSONSchemaBridge.ts 100.00% <100.00%> (ø)
packages/uniforms/src/joinName.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80b6a38...a54a7fb. Read the comment docs.

Copy link
Contributor

@radekmie radekmie left a comment

Choose a reason for hiding this comment

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

  1. What if a field is called [""]? I know, it's a terrible name, but it's possible.
  2. More generally, what if the field contains an arbitrary number of [""]? Like, [""][""], ["[""]"], or ["[""]"]["[""]"]?

@radekmie radekmie added the Type: Feature New features and feature requests label Jan 21, 2022
@radekmie radekmie closed this Jan 28, 2022
@radekmie radekmie deleted the json-schema-dot-names branch January 28, 2022 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New features and feature requests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Valid JSON Schema with Dot-Fieldnames breaks JSONSchemaBridge 3.5.1
2 participants