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.

additionalProperties form - enum for key

See original GitHub issue

Prerequisites

Description

Would it be possible to add a feature that would enable the user to set a given set of all possible keys of additionalProperties?

At the moment, I validate the keys with propertyNames which works, but it would be much cleaner for the user to have it set as an enum.

Expected behavior

additionalProperties are rendered with a dropdown key selection if enum given.

Actual behavior

additionalProperties have to options for key customizations and propertyNames are ignored in the rendering phase (but used for validation).

Version

Latest.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bmschmidtcommented, Apr 17, 2019

Not the OP, but as it happened was just googling for almost this same issue. My expected behavior was that, when there is a constraint on property names, the interface elements will use dropdowns for the keys to any additionalProperties.

For example, in the following schema, when you add another property to the array with a plus button, the values of the properties give you a dropdown to choose from “val1” and “val2”, but you just get a text field to write into without any hints about permitted values are. Instead, it should be a dropdown to choose from ‘foo’ or ‘bar.’

{
  "type": "object",
  "propertyNames": {
    "enum": [
      "foo",
      "bar"
    ],
    "type": "string"
  },
  "additionalProperties": {
    "type": "string",
    "enum": [
      "val1",
      "val2"
    ]
  }
}

Great library, thanks for your work.

0reactions
stale[bot]commented, Apr 15, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Properties based on enum value in JSON Schema
I'm building a json schema definition which has a fixed set of controls that I've currently limited with an enum . However, not...
Read more >
object — Understanding JSON Schema 2020-12 documentation
In JSON, the “keys” must always be strings. Each of these pairs is conventionally referred to as a “property”. Language-specific info: Python; Ruby....
Read more >
Objects - react-jsonschema-form documentation
The additionalProperties keyword allows the user to add properties with arbitrary key names. Set this keyword equal to a schema object:
Read more >
Edit form and Display form controls in Power Apps
Description; Key properties; Additional properties; More information; Accessibility guidelines. Display, edit, and create a record in a data ...
Read more >
Dictionaries, Hashmaps, Associative Arrays - Swagger
OpenAPI lets you define dictionaries where the keys are strings. ... values can be of any type (aka free-form object), use additionalProperties: true...
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