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

How to select oneOf value #2528

Closed
rohitb7 opened this issue Oct 3, 2020 · 4 comments · Fixed by #3152
Closed

How to select oneOf value #2528

rohitb7 opened this issue Oct 3, 2020 · 4 comments · Fixed by #3152

Comments

@rohitb7
Copy link

rohitb7 commented Oct 3, 2020

https://stackblitz.com/edit/angular-vv82f7?file=src%2Fassets%2Fjson-schema%2Fschema_dependencies.json

Check "schema_dependencies" in stackblitz

				"items": {
					"type": "object",
					"properties": {
						"mainKey": {
							"oneOf": [{
									"type": "string",
									"description": "Route policy contents as a single quoted string",
									"format": "WORD"
								},
								{
									"type": "null",
									"description": "Set value to null to delete this leaf"
								}
							]
						}
					},
					"additionalProperties": false,
				},

I want to pick/assign oneOf the values to the mainKey .

Objects inside oneOf can be of any type, hence I cannot assign type : ' object ' to the mainKey

because then it will always give me { mainKey : {} } which cannot be true always,

**since the value can be any string { mainKey : "abc" }, number { mainKey : 123 } , etc **

I guess there should some dynamic behavior for this.

@aitboudad
Copy link
Member

We don't support a such format yet, try with the following schema:

"items": {
  "type": "object",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "mainKey": {
          "type": "string",
          "description": "Route policy contents as a single quoted string",
          "format": "WORD"
        }
      }
    },
    {
      "type": "object",
      "properties": {
        "mainKey": {
          "type": "null",
          "description": "Set value to null to delete this leaf"
        }
      }
    }
  ]
}

@rohitb7
Copy link
Author

rohitb7 commented Oct 3, 2020

Thanks for your quick reply. When can we expect this enhancement?

@aitboudad
Copy link
Member

within 1 or 2 weeks

@aitboudad
Copy link
Member

This issue has been fixed and released as part of v5.12.0 release.

Please let us know, in case you are still encountering a similar issue/problem.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants