question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When using data generated by a schema containing anyof, the result is incorrect after assignment to the editor.

See original GitHub issue

Expected behavior

The editor can correctly assign values based on json

Actual behavior

The editor cannot use the correct anyOf subkey when assigning the anyOf field

Steps to reproduce the behavior

schema

{
  "title": "anyof badcase",
  "type": "object",
  "properties": {
    "items": {
      "title": "title",
      "type": "array",
      "format": "tabs",
      "items": {
        "title": "item",
        "headerTemplate": "{{self.handler}}",
        "options": {
          "keep_oneof_values": false
        },
        "anyOf": [
          {
            "title": "item a",
            "properties": {
              "handler": {
                "default": "aaa"
              },
              "___a": {
                "title": "___",
                "type": "string"
              }
            }
          },
          {
            "title": "item b",
            "properties": {
              "handler": {
                "default": "bbb"
              },
              "___b": {
                "title": "___",
                "type": "string"
              }
            }
          },
          {
            "title": "item c",
            "properties": {
              "params": {
                "properties": {
                  "items": {
                    "title": "sub items",
                    "type": "array",
                    "format": "tabs",
                    "items": {
                      "options": {
                        "keep_oneof_values": false
                      },
                      "title": "sub item",
                      "headerTemplate": "{{self.handler}}",
                      "anyOf": [
                        {
                          "title": "item a",
                          "properties": {
                            "handler": {
                              "default": "aaa"
                            },
                            "___a": {
                              "title": "___",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "title": "item b",
                          "properties": {
                            "handler": {
                              "default": "bbb"
                            },
                            "___b": {
                              "title": "___",
                              "type": "string"
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              },
              "handler": {
                "default": "ccc"
              },
              "___c": {
                "title": "___",
                "type": "string"
              }
            }
          }
        ]
      }
    }
  }
}

generated data:

{
  "items": [
    {
      "handler": "aaa",
      "___a": ""
    },
    {
      "handler": "bbb",
      "___b": ""
    },
    {
      "params": {
        "items": [
          {
            "handler": "aaa",
            "___a": ""
          },
          {
            "handler": "bbb",
            "___b": ""
          },
          {
            "handler": "aaa",
            "___a": ""
          }
        ]
      },
      "handler": "ccc",
      "___c": ""
    }
  ]
}

Update the editor with the generated data.

screenshot

screenshot

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
drzaxcommented, Feb 18, 2019

Sorry, I don’t have time for that and the bug is already explained quite well here. I just wanted to point out that this is still a bug, and rather an annoying one which is difficult to track down. Feel free to use/manage this bug report however you think is appropriate.

On Mon, 18 Feb 2019 at 06:17, Peter Klein notifications@github.com wrote:

@drzax https://github.com/drzax I suggest you open a new issue with specific examples etc. As it looks like the the original reporters is no longer around.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/json-editor/json-editor/issues/128#issuecomment-464503725, or mute the thread https://github.com/notifications/unsubscribe-auth/AAkaUx5iEv59X8SXUflLedOwHQwjwivGks5vObj1gaJpZM4VFM44 .

3reactions
drzaxcommented, Jan 29, 2019

In my opinion this ticket should not have been closed. As far as I can tell, there is still no foolproof way to ensure that the correct schema is used for children in a oneOf or anyOf when loading data.

The comment suggesting this has been fixed uses data that makes it appear to work, but as @wclssdn commented earlier it still doesn’t work if the sub-items are more complex and the data (although unambiguously matching a specific schema) is incomplete.

To test this, load up the schema link posted by @pmk65 in the comment declaring this fixed, but then refresh the form using data from @Richacinas comment and you will see that the third item (ccc) now incorrectly uses the aaa schema.

Read more comments on GitHub >

github_iconTop Results From Across the Web

oneOf, anyOf, allOf, not - Swagger
Use the anyOf keyword to validate the data against any amount of the given subschemas. That is, the data may be valid against...
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
W3C XML Schema Definition Language (XSD) 1.1 Part 1
Abstract. This document specifies the XML Schema Definition Language, which offers facilities for describing the structure and constraining ...
Read more >
Documentation: 15: 5.9. Schemas - PostgreSQL
The first element specifies that a schema with the same name as the current user is to be searched. If no such schema...
Read more >
Image Classification Wizard—ArcGIS Pro | Documentation
If you want to assess the accuracy of classified results, you need to provide a reference dataset. Reference data consists of features with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found