JSON Schema Validation - Why is required not being enforced? - json

I've been trying to create a JSON Schema and have been using an online validation tool http://jsonschemalint.com/. I made a change to my JSON object that I expected to fail against my schema but it didn't - so I think I must have made a mistake somewhere. Can anyone explain to my why the following change doesn't cause a validation error?
Schema
{
"title": "Control Configuration Array",
"description": "An array of the configurations",
"type": "array",
"minItems": 1,
"items": {
"group": {
"title": "Control Grouping",
"description": "Represents a logical grouping of controls",
"type": "object",
"properties": {
"value": {
"title": "Group Label",
"description": "The label to use for the group",
"type": "string"
},
"sortIndex": {
"title": "Sort Index",
"description": "The order in which the groups appear",
"type": "number",
"minimum": 0
},
"cssClass": {
"title": "Group CSS",
"description": "The CSS class to apply to the group label",
"type": "string"
},
"controls": {
"title": "Controls",
"description": "The set of controls within this group",
"type": "array",
"minItems": 1,
"required": true,
"items": {
"config": {
"title": "Control Configuration",
"description": "The main configuration object for a control and its associated dependencies",
"type": "object",
"properties": {
"id": {
"title": "Control ID",
"description": "The identifier for the control set which will be used in dependencies",
"type": "string",
"required": true
},
"sortIndex": {
"title": "Sort Index",
"description": "The order in which the controls appear",
"type": "number",
"minimum": 0
},
"label": {
"title": "Label",
"description": "Describes the label for the control group",
"type": "object",
"properties": {
"value": {
"title": "Caption",
"description": "The caption to place in the label",
"type": "string"
},
"cssClass": {
"title": "Label CSS Classes",
"description": "The CSS classes to apply to the label, separated with spaces",
"type": "string"
},
"tooltipText": {
"title": "Tooltip",
"description": "The tooltip to apply to the label and control",
"type": "string"
}
}
},
"control": {
"title": "Control",
"description": "Describes the control for the control group",
"type": "object",
"required": true,
"properties": {
"type": {
"title": "Control Type",
"description": "The type of control that should be displayed",
"type": "string",
"enum": [
"text",
"radio",
"dropdown",
"checkbox",
"color",
"date",
"datetime",
"search",
"email",
"url",
"tel",
"number",
"range",
"month",
"week",
"time",
"datetime-local"
]
},
"options": {
"title": "Avaliable Options",
"description": "The set of avaliable options for all selection controls (e.g. radio, dropdown)",
"type": "array"
},
"value": {
"title": "The current value of the control",
"description": "This is the inital value or selected value of the control",
"type": "object",
"required": true
},
"cssClass": {
"title": "Control CSS Classes",
"description": "The CSS classes to apply to the control, separated with spaces",
"type": "string"
}
}
},
"dependencies": {
"title": "Dependencies",
"description": "Describes the dependencies between this and other controls",
"type": "object",
"properties": {
"enabled": {
"title": "Enabled",
"description": "The properties to determine if the control should be enabled or not",
"type": "object",
"properties": {
"targetID": {
"title": "Enabled Target ID",
"description": "The ID of the target control, whose value must match one of the target values for this control to be enabled",
"type": "string",
"required": true
},
"targetValues": {
"title": "Enabled target values",
"description": "The set of values which if selected in the target control will cause this control to be enabled",
"type": "array",
"required": true
}
}
},
"display": {
"title": "Display",
"description": "The properties to determine if the control should be displayed or not",
"type": "object",
"properties": {
"targetID": {
"title": "Display Target ID",
"description": "The ID of the target control, whose value must match one of the target values for this control to be displayed",
"type": "string",
"required": true
},
"targetValues": {
"title": "Display target values",
"description": "The set of values which if selected in the target control will cause this control to be displayed",
"type": "array",
"required": true
}
}
}
}
},
"validation": {
"title": "Validation",
"description": "Describes the validation of the control value",
"type": "object",
"properties": {
"required": {
"title": "Required",
"description": "Whether the field is required",
"type": "boolean"
},
"min": {
"title": "Minimum",
"description": "The minimum value that the control is allowed",
"type": "number"
},
"max": {
"title": "Maximum",
"description": "The maximum value that the control is allowed",
"type": "number"
},
"minLength": {
"title": "Minimum Length",
"description": "The minimum length that the control is allowed",
"type": "integer"
},
"maxLength": {
"title": "Maximum Length",
"description": "The maximum length that the control is allowed",
"type": "integer"
},
"pattern": {
"title": "Regex Pattern",
"description": "A regex pattern to use for validation",
"type": "string"
},
"step": {
"title": "Increment Step",
"description": "An increment check that must be met - generally combine with min/max",
"type": "number"
},
"email": {
"title": "Email",
"description": "Whether the field must be an email address",
"type": "boolean"
},
"equal": {
"title": "Equals",
"description": "Ensure the field equals the other object",
"type": "object"
},
"notEqual": {
"title": "Not Equals",
"description": "Ensure the field does not equal the other object",
"type": "object"
},
"date": {
"title": "Date",
"description": "Whether the field must be a date",
"type": "boolean"
},
"dateISO": {
"title": "Date ISO",
"description": "Whether the field must be an ISO date",
"type": "boolean"
},
"number": {
"title": "Number",
"description": "Whether the field must be a number",
"type": "boolean"
},
"digit": {
"title": "Digit",
"description": "Whether the field must be a digit",
"type": "boolean"
}
}
}
}
}
}
}
}
}
}
}
JSON
[
{
"value": "Group1",
"cssClass": "red",
"sortIndex": 1,
"controls": [
{
"id": "ConfigType",
"sortIndex": 1,
"label": {
"value": "Configuration Type",
"cssClass": "label",
"tooltipText": "Configuration Type Tooltip"
},
"control": {
"type": "radio",
"options": [
"Single Deck",
"Level"
],
"value": "Single Deck",
"cssClass": "control"
}
},
{
"id": "AppType",
"sortIndex": 2,
"label": {
"value": "Application Type",
"cssClass": "label",
"tooltipText": "Application Type Tooltip"
},
"control": {
"type": "dropdown",
"options": [
"Other",
"Other2"
],
"value": "Other",
"cssClass": "red"
},
"dependencies": {
"enabled": {
"targetID": "ConfigType",
"targetValues": [
"Level"
]
},
"display": {
"targetID": "ConfigType",
"targetValues": [
"Level"
]
}
}
},
{
"id": "textType",
"label": {
"value": "Text Type",
"cssClass": "label",
"tooltipText": "text Type Tooltip"
}
}
]
}
]
Change
Find "targetID" : "ConfigType" under either the enabled or display dependency. Remove this line. This should then fail as these are both required fields according to the schema. However it doesn't seem to fail...

First I would recommend you move to draft 4 which have some improvements (required is provided in an array).
jsonschemalint is using draft 3. Afaik "items" constraint has not changed. You can provide a boolean value, an object or one array of objects.
In your case, you have provided one object-schema but incorrectly. "group" and "config" labels are not necessary. For instance, given the following json object in draft 3:
[{}]
This schema (similar as yours) validates the data:
{
"type" : "array",
"minItems" : 1,
"items" : {
"unnecesaryLabel" : {
"type" : "object",
"properties" : {
"one" : {
"required" : true
}
}
}
}
}
And this makes the data invalid:
{
"type" : "array",
"minItems" : 1,
"items" : {
"type" : "object",
"properties" : {
"one" : {
"required" : true
}
}
}
}

Related

How to check for matching properties using a JSON schema?

I'm making a Discord bot in Python that reacts to certain keywords in messages and my script uses a JSON file that might for example look like this:
{
"characters": {
"john": {
"name": "Johnny",
"hex_colour": "0xC61B1B"
},
"marc": {
"name": "Marcus",
"hex_colour": "0x8AC0FF"
}
},
"reactions": [
{
"keywords": ["Hi", "Hello"],
"quotes": {
"john": ["Hello my name is Johnny"]
"marc": [
"Hi there. I'm Marcus.",
"Not now, I'm looking for John, have you seen him?"
]
}
},
{
"keywords": ["Bye"],
"quotes": {
"john": ["See you later!"]
}
}
]
}
As you can see the structure is quite complex, so I decide to make a schema for it so vscode could point out any issues. It currently looks like this:
{
"title": "Quotes data",
"description": "Quotes bot data file",
"type": "object",
"properties": {
"characters": {
"title": "Character collection",
"description": "A collection of the available characters.",
"type": "object",
"additionalProperties":{
"title": "Character tag",
"description": "A tag that represents the character as a short string",
"type": "object",
"properties": {
"name": {
"title": "Character name",
"description": "The name of the character.",
"type": "string"
},
"hex_colour": {
"title": "Character colour",
"description": "The hex code of the colour in 0x000000 format.",
"type": "string"
},
"image_url": {
"title": "Character image",
"description": "An url to an image of the character.",
"type": "string"
}
},
"required": ["name"],
"additionalProperties": false
}
},
"reactions": {
"title": "Reaction collection",
"description": "A list of the reactions",
"type": "array",
"items": {
"type": "object",
"properties": {
"keywords": {
"title": "Keyword list",
"description": "A list of keywords for the bot to react to.",
"type": "array",
"items": {
"title": "Keyword",
"type": "string",
"minItems": 1,
"uniqueItems": true
}
},
"quotes": {
"title": "Quotes collection",
"description": "A collection of characters with quotes.",
"type": "object",
"additionalProperties":{
"title":"Character tag",
"description": "A tag that matches a character above.",
"type": "array",
"items": {
"title": "Quote",
"description": "A quote to react with.",
"type": "string",
"minItems": 1,
"uniqueItems": true
}
}
}
},
"required": ["keywords", "quotes"],
"additionalProperties": false
}
}
},
"required": ["characters", "reactions"],
"additionalProperties": true,
"allowTrailingCommas": true
}
So for the properties of the "characters" object, any property name is allowed, therefore I use "additionalProperties". Later on, for the "quotes" object, I did the same. But in this case, not any property should be allowed. Only those that match one of the properties of the "characters" object is allowed. Is there any way to make the schema check for matching properties?
This is a very specific semantic check and not possible using the standard specification of JSON Schema. Validation can't access an arbitrary set of property names and also can't look up the validation path. You would need to add this as application code.

Convert Nested Json Schem to Pyspark Schema

I have a schema which has nested fields.When I try to convert it with:
jtopy=json.dumps(schema_message['SchemaDefinition']) #json.dumps take a dictionary as input and returns a string as output.
print(jtopy)
dict_json=json.loads(jtopy) # json.loads take a string as input and returns a dictionary as output.
print(dict_json)
new_schema = StructType.fromJson(dict_json)
print(new_schema)
It returns error:
return StructType([StructField.fromJson(f) for f in json["fields"]])
TypeError: string indices must be integers
The schema is Definition as described below is what Im passing
{
"type": "record",
"name": "tags",
"namespace": "com.tigertext.data.events.tags",
"doc": "Schema for tags association to accounts (role,etc..)",
"fields": [
{
"name": "header",
"type": {
"type": "record",
"name": "eventHeader",
"namespace": "com.tigertext.data.events",
"doc": "Metadata about the event record.",
"fields": [
{
"name": "topic",
"type": "string",
"doc": "The topic this record belongs to. e.g. messages"
},
{
"name": "server",
"type": "string",
"doc": "The server that generated this event. e.g. xmpp-07"
},
{
"name": "service",
"type": "string",
"doc": "The service that generated this event. e.g. erlang-producer"
},
{
"name": "environment",
"type": "string",
"doc": "The environment this record belongs to. e.g. dev, prod"
},
{
"name": "time",
"type": "long",
"doc": "The time in epoch this record was produced."
}
]
}
},
{
"name": "eventType",
"type": {
"type": "enum",
"name": "eventType",
"symbols": [
"CREATE",
"UPDATE",
"DELETE",
"INIT"
]
},
"doc": "event type"
},
{
"name": "tagId",
"type": "string",
"doc": "Tag ID for the tag"
},
{
"name": "orgToken",
"type": "string",
"doc": "org ID"
},
{
"name": "tagName",
"type": "string",
"doc": "name of the tag"
},
{
"name": "colorId",
"type": "string",
"doc": "color id"
},
{
"name": "colorName",
"type": "string",
"doc": "color name"
},
{
"name": "colorValue",
"type": "string",
"doc": "color value e.g. #C8C8C8"
},
{
"name": "entities",
"type": [
"null",
{
"type": "array",
"items": {
"type": "record",
"name": "entity",
"fields": [
{
"name": "entityToken",
"type": "string"
},
{
"name": "entityType",
"type": "string"
}
]
}
}
],
"default": null
}
]
}
Above is the schema of the kafka topic I want to parse into pyspark schema

Swagger JSON - How could I fix a response render error?

I have been trying to fix an error where the Swagger would not render my JSON response - here is an attached picture of it.
The console does not show any errors so I am struggling to allocate from where the issue could be coming - here is the console result.
I would be extremely thankful if someone could suggest a way to fix that problem.
Here is my code:
"paths": {
"/unit/{jobs}": {
"get": {
"tags": [
"Services"
],
"summary": "Jobs information",
"description": "Returns JSON with content of jobs details.",
"operationId": "unitJobs",
"security": [
{
"Application": []
},
{
"Profile": []
},
{
"Authorization": []
}
],
"parameters": [
{
"name": "jobs",
"in": "path",
"required": true,
"schema": {
"type": "string"
},
"description": "Jobs"
}
],
"responses": {
"200": {
"description": "Success!",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Job"
}
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"Application": {
"name": "X-Application",
"type": "apiKey",
"in": "header"
},
"Profile": {
"name": "X-Profile",
"type": "apiKey",
"in": "header"
},
"Authorization": {
"type": "http",
"scheme": "bearer"
}
},
"schemas": {
"Job": {
"properties": {
"id": {
"type": "integer",
"example": 2584075,
"description": "Unique identifier"
},
"currency_code": {
"type": "string",
"example": "GBP",
"description": "Currency code"
},
"payment_method": {
"type": "array"
},
"app_time": {
"type": "integer",
"example": 1504620000,
"description": "Appointment time for the job in UTC timestamp"
},
"flexible_from": {
"type": "integer",
"example": null,
"description": "Start of timeframe to execute the job in UTC timestamp"
},
"flexible_to": {
"type": "integer",
"example": null,
"description": "End of timeframe to execute the job in UTC timestamp"
},
"insufficient_travel_time_warning_time": {
"type": "integer",
"example": "1504616400",
"description": "Time up until Pro should leave previous job in order to get to this job in time in UTC timestamp"
},
"total_formatted": {
"type": "string",
"example": "£97",
"description": "Price of the service after discounts"
},
"base_total_formatted": {
"type": "string",
"example": "£97",
"description": "Price of the service before discounts"
},
"price_notes": {
"type": "array",
"example": [
"Credit applied",
"Compensation included"
],
"description": "Description notes for the price of the services."
},
"require_summary": {
"type": "integer",
"example": 4,
"description": "\n * `0` - No summary required \n * `1` - Should send summary at the end of the day \n * `2` - Should send summary now \n * `3` - Can’t proceed until summary sent \n * `4` - Summary sent"
},
"work_time": {
"type": "integer",
"example": 120,
"description": "Job duration in minutes"
},
"valid_to": {
"type": "integer",
"example": "1504620000",
"description": "Time after which job is no more valid and has to be updated in UTC timestamp"
},
"attachments.origin_key": {
"type": "string",
"example": "checklist",
"description": "\n Identifies where the attachment is coming from: \n * `checklist` - from answering a question that requires attachment \n * `job` - from job screen \n * `configurator` - from booking process when filling a choice item of type attachment"
},
"services_price_modifiers": {
"type": "array",
"example": ""
},
"reference_number": {
"type": "string",
"example": "20082602SYS",
"description": "Unique identifying number for each job"
},
"purchase_order_number": {
"type": "string",
"example": "12-13-14-15-16",
"description": "Unique number assigned to a purchase order form"
},
"contacts": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Contact"
}
},
"message_templates": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MessageTemplate"
}
},
"decline_reason_groups": {
"type": "array",
"items": {
"$ref": "#/components/schemas/DeclineReasonGroup"
}
},
"icons": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Icon"
}
}
}
},
"Contact": {
"properties": {
"id": {
"type": "integer",
"example": 203,
"description": "Unique identifier"
},
"value": {
"type": "string",
"example": "02034042956",
"description": "Contact number"
},
"type": {
"$ref": "#/components/schemas/ContactType"
},
"description": {
"type": "string",
"example": "Customer Service",
"description": "Name of the corresponding department"
},
"display_positions": {
"type": "array",
"example": [
2,
3,
7
],
"description": ""
}
}
},
"MessageTemplate": {
"properties": {
"id": {
"type": "integer",
"example": 15,
"description": "Unique identifier"
},
"title": {
"type": "string",
"example": "In front of the property",
"description": "Template message title"
},
"message": {
"type": "string",
"example": "Dear [CLIENT_NAME], I am in front of your property. Please let me in or call our office on 02034041930. Your Fantastic Professional",
"description": "The containing text of the message"
},
"vars": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Var"
},
},
"destination_option_title": {
"type": "string",
"example": "to office",
"description": "Optionally defines the destination of the title"
}
}
},
"DeclineReasonGroup": {
"properties": {
"title": {
"type": "string",
"example": "Technical issues",
"description": "Decline reason title"
},
"sort": {
"type": "integer",
"example": 100,
"description": ""
},
"decline_reasons": {
"type": "array",
"items": {
"$ref": "#/components/schemas/DeclineReason"
}
}
}
},
"Icon": {
"properties": {
"name": {
"type": "string",
"example": "Key:",
"description": "The name of the icon"
},
"note": {
"type": "string",
"example": "Yes",
"description": "Addiditonal information about the icon"
}
}
},
"Var": {
"properties": {
"variable": {
"type": "string",
"example": "CLIENT_NAME",
"description": "Different client details"
},
"type": {
"$ref": "#/components/schemas/VarType"
},
"field": {
"type": "string",
"example": "clientName",
"description": "Fields where the client's information is filled"
}
}
},
"DeclineReason": {
"properties": {
"id": {
"type": "integer",
"example": 11,
"description": "Unique identifier"
},
"name": {
"type": "string",
"example": "Car is broken",
"description": "The name of a decline reason"
},
"requires_comment": {
"type": "boolean",
"example": true,
"description": "Determines whether the comment section is required to be filled "
},
"success_message": {
"type": "string",
"example": "Please contact Stanimir Tomov on 07472761402 - he can find you another.",
"description": "The message which pops up after the request made is successful"
},
"sort": {
"type": "integer",
"example": 100,
"description": ""
}
}
},
"ContactType": {
"type": "integer",
"enum": [
1,
2,
3,
4
],
"description": "* `1` - Customer Service \n * `2` - Sales \n * `3` - Finance \n * `4` - Other"
},
"VarType": {
"type": "string",
"enum": [
"auto",
"manual"
],
"description": "* `auto` - information being filled automatically \n * `manual` - information being filled manually "
}
}
}
}
The problem is not the responses them selves, rather it is the definition of the 'payment_method' in the Job schema:
You need to define the items in an array definition, try this:
"payment_method": {
"type": "array",
"items": {
"type": "string"
}
}

JSON Schema dependency based on minimum value

I am trying to add a dependency to a property based on the property value before it. Within my JSON, there is an instances property. If that property is > 2 only then show the StartIndex property. I have tried adding another if-then-else to my pre-existing one (wrapped in an allOf) but that was failing so I decided to take the dependency route.
Here's the JSON Schema with my attempt at adding the dependency withing the StartIndex property:
{
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://example.com/root.json",
"type": "object",
"title": " ",
"required": [
"NetworkProfile",
"GroupEmailAddress",
"FILESTORAGE",
"Memory",
"Instances",
"StartIndex"
],
"properties": {
"Name": {
"$id": "#/properties/Name",
"type": "string",
"title": "Name",
"default": "",
"description": "The first five characters are generated per specs. Specify the next eight characters here and we suggest: Data Center (2), Layer (2-3), Sequential Number (2).",
"examples": [
""
],
"minLength": 0,
"maxLength": 8,
"pattern": "^[a-zA-Z0-9]*$",
"validationMessages": {
"pattern": "Must contain only alphanumeric characters.",
"required": "Must contain only alphanumeric characters."
}
},
"Instances": {
"$id": "#/properties/Instances",
"default": 2,
"examples": [
"2"
],
"pattern": "^(.*)$",
"title": "Number of VM Node",
"description": "Number of VM instance in this request",
"minimum": 1,
"maximum": 5,
"type": "number"
},
"StartIndex": {
"dependencies": {
"Instances": {
"minimum": 2
}
},
"$id": "#/properties/StartIndex",
"default": 1,
"examples": [
"1"
],
"pattern": "^(.*)$",
"title": "Start Index for these VMs",
"description": "The starting sequence number for this set of servers",
"type": "number",
"minimum": 1
},
"Memory": {
"$id": "#/properties/Memory",
"type": "number",
"enum": [
4,
8,
16
],
"title": "RAM (GB)",
"default": 4,
"examples": [
""
],
"pattern": "^(.*)$"
},
"GroupEmailAddress": {
"$id": "#/properties/GroupEmailAddress",
"type": "string",
"title": "Group Email Address",
"default": "",
"description": "This should be an email address for your application group. Security will use this email address to contact when TLS cert needs to be renewed.",
"examples": [
""
]
},
"User": {
"$id": "#/properties/User",
"type": "string",
"title": "Admin Group",
"default": "",
"examples": [
""
],
"description": "The user account that will have access to the vm. Default belong to requester if not specified. Additional users can be added by using a comma(,) as a separator. <br> (e.g. Americas\\firstName_lastName). Only PAC group is accepted for PROD.",
"pattern": "^((Americas|Asia-Pacific|Europe)\\\\.[a-zA-Z0-9_.%]*[*,]?[\\s]*)*$"
},
"NetworkProfile": {
"$id": "#/properties/NetworkProfile",
"type": "string",
"enum": [
"APP",
"WEB"
],
"title": "Server Type/Function",
"description": "Web Server is meant to serve static pages e.g. HTML and CSS, while Application Server is responsible for generating dynamic content by executing server side code.",
"default": "",
"examples": [
""
],
"pattern": "^(.*)$"
},
"eDell": {
"$id": "#/properties/eDell",
"title": "Is the VM related to eDell? ",
"type": "boolean",
"default": false
},
"Disks": {
"$id": "#/properties/Disks",
"type": "array",
"title": "Local (Non-OS) Storage. Default OS Drive (C) size is 60GB. The (D) drive is fixed at 20 GB, can use E-Z for additional storage. Can only add an additional 900GB.",
"items": {
"$id": "#/properties/Disks/items",
"type": "object",
"title": " ",
"required": [
"data"
],
"properties": {
"data": {
"$id": "#/properties/Disks/items/properties/data",
"type": "object",
"title": " ",
"required": [
"capacity",
"initial_location"
],
"properties": {
"capacity": {
"$id": "#/properties/Disks/items/properties/data/properties/capacity",
"type": "number",
"title": "Capacity (GB)",
"default": "",
"examples": [
"20"
],
"minimum": 5,
"maximum": 900
},
"initial_location": {
"$id": "#/properties/Disks/items/properties/data/properties/initial_location",
"type": "string",
"title": "Drive Letter",
"default": "E",
"examples": [
"/u02"
],
"description": "Drive Letter of the partition without colon",
"pattern": "^[eE,fF,gG,hH,iI,jJ,kK,lL,mM,nN,oO,pP,qQ,rR,sS,tT,uU,vV,wW,xX,yY,zZ]{1}$",
"validationMessages": {
"pattern": "C,D are reserved use E-Z.",
"required": "C,D are reserved use E-Z."
}
}
}
}
}
}
},
"FILESTORAGE": {
"$id": "#/FileStorage",
"type": "string",
"enum": [
"YES",
"NO"
],
"title": "Add File Storage",
"default": "NO",
"examples": [
""
],
"pattern": "^(.*)$"
}
},
"if": {
"properties": {
"FILESTORAGE": {
"const": "YES"
}
}
},
"then": {
"properties": {
"NASDisk": {
"$id": "#/properties/NASDisk",
"type": "object",
"title": "File Storage",
"required": [
"AppName",
"SizeGB",
"Protocol",
"ShareOwner",
"Function"
],
"properties": {
"Protocol": {
"$id": "#/properties/NASDisk/properties/Protocol",
"type": "string",
"default": "CIFS",
"options": {
"hidden": "true"
}
},
"Function": {
"$id": "#/properties/NASDisks/properties/Function",
"type": "string",
"enum": [
"File",
"Storage",
"Backup",
"App",
"Log",
"Database",
"Repository"
],
"title": "Choose Function for NAS",
"default": "File",
"examples": [
""
],
"pattern": "^(.*)$"
},
"AppName": {
"$id": "#/properties/NASDisk/properties/AppName",
"type": "string",
"title": "App Name",
"default": "",
"description": "Abbreviation or alias of the application name to be prefix to the share name, limit to 10 letters",
"pattern": "^[a-zA-Z]{1,10}$"
},
"SizeGB": {
"$id": "#/properties/NASDisk/properties/SizeGB",
"type": "number",
"title": "Size (GB)",
"default": 5,
"examples": [
5
],
"minimum": 5,
"maximum": 500
},
"ShareOwner": {
"$id": "#/properties/NASDisk/properties/ShareOwner",
"type": "string",
"title": "Share Owner",
"default": "",
"description": "User account with ownership of the share. Group ownership can be specified using the format DOMAIN\\UserName. <br> (e.g. Americas\\firstName_lastName).",
"examples": [
"adms_c_lawlor"
],
"pattern": "^((Americas|Asia-Pacific|Europe)\\\\.[a-zA-Z0-9_.%]*[*,]?[\\s]*)*$"
},
"FC_Members": {
"$id": "#/properties/NASDisk/properties/FC_Members",
"type": "string",
"description": "Comma separated AD groups that will have full control of share."
},
"RW_Members": {
"$id": "#/properties/NASDisk/properties/RW_Members",
"type": "string",
"description": "Comma separated AD groups that will have read/write control of share."
}
}
}
}
},
"else": {}
}
Here was my allOf attempt:
"allOf": [
{
"if": {
"properties": {
"FILESTORAGE": {
"const": "YES"
}
}
},
"then": {
"properties": {
"NASDisk": {
"$id": "#/properties/NASDisk",
"type": "object",
"title": "File Storage",
"required": [
"AppName",
"SizeGB",
"Protocol",
"ShareOwner",
"Function"
],
"properties": {
"Protocol": {
"$id": "#/properties/NASDisk/properties/Protocol",
"type": "string",
"default": "CIFS",
"options": {
"hidden": "true"
}
},
"Function": {
"$id": "#/properties/NASDisks/properties/Function",
"type": "string",
"enum": [
"File",
"Storage",
"Backup",
"App",
"Log",
"Database",
"Repository"
],
"title": "Choose Function for NAS",
"default": "File",
"examples": [
""
],
"pattern": "^(.*)$"
},
"AppName": {
"$id": "#/properties/NASDisk/properties/AppName",
"type": "string",
"title": "App Name",
"default": "",
"description": "Abbreviation or alias of the application name to be prefix to the share name, limit to 10 letters",
"pattern": "^[a-zA-Z]{1,10}$"
},
"SizeGB": {
"$id": "#/properties/NASDisk/properties/SizeGB",
"type": "number",
"title": "Size (GB)",
"default": 5,
"examples": [
5
],
"minimum": 5,
"maximum": 500
},
"ShareOwner": {
"$id": "#/properties/NASDisk/properties/ShareOwner",
"type": "string",
"title": "Share Owner",
"default": "",
"description": "User account with ownership of the share. Group ownership can be specified using the format DOMAIN\\UserName. <br> (e.g. Americas\\firstName_lastName).",
"examples": [
"adms_c_lawlor"
],
"pattern": "^((Americas|Asia-Pacific|Europe)\\\\.[a-zA-Z0-9_.%]*[*,]?[\\s]*)*$"
},
"FC_Members": {
"$id": "#/properties/NASDisk/properties/FC_Members",
"type": "string",
"description": "Comma separated AD groups that will have full control of share."
},
"RW_Members": {
"$id": "#/properties/NASDisk/properties/RW_Members",
"type": "string",
"description": "Comma separated AD groups that will have read/write control of share."
}
}
}
}
},
"else": {
}
},
{
"if": {
"properties": {
"Instances": {
"minimum": "1"
}
}
},
"then": {
"properties": {
"StartIndex": {
"$id": "#/properties/StartIndex",
"hidden": true,
"default": "1",
"examples": [
"1"
],
"pattern": "^(.*)$",
"title": "Start Index for these VMs",
"description": "The starting sequence number for this set of servers",
"type": "number",
"minimum": 0
}
}
},
"else": {
"properties": {
"StartIndex": {
"$id": "#/properties/StartIndex",
"default": "",
"examples": [
"1"
],
"pattern": "^(.*)$",
"title": "Start Index for these VMs",
"description": "The starting sequence number for this set of servers",
"type": "number",
"minimum": 0
}
}
}
}
]
UPDATE: So I actually figure this out using nested properties as shown here
"isMultiDropdown": {
"title": "",
"$id": "#/properties/isMultiDropdown",
"required": [
"isMulti"
],
"type": "object",
"if": {
"properties": {
"isMulti": {
"const": "YES"
}
}
},
"then": {
"properties": {
"StartIndex": {
"$id": "#/properties/StartIndex",
"default": "",
"examples": [
"1"
],
"pattern": "^(.*)$",
"title": "Start Index for these VMs",
"description": "The starting sequence number for this set of servers",
"type": "number",
"minimum": 0
}
}
},
"properties": {
"isMulti": {
"$id": "#/properties/isMultiDropdown/isMulti",
"enum": [
"YES",
"NO"
],
"title": "Are you provisioning multiple instances?",
"default": "NO",
"examples": [
""
],
"pattern": "^(.*)$",
"type": "string"
}
}
}
```

In MS Power Automate, how to populate dynamic property dropdown value using the result from another action?

I created an action in MS Power Automation (Flow) that I want to dynamically generate the dropdown values. I follow the documentation and examples listed here:
Documentation: https://learn.microsoft.com/en-us/connectors/custom-connectors/openapi-extensions#use-dynamic-values
Example: https://github.com/microsoft/PowerPlatformConnectors/blob/97c0317f96dc1d9601ef2d0e76f826e83bd14351/connectors/Planner/apiDefinition.swagger.json
I setup my flow exactly as described in the official documents:
"/MyFlow/MyAction": {
"post": {
"description": "This is my action",
"operationId": "MyAction",
"parameters": [
{
"description": "Please select from the dropdown",
"in": "header",
"name": "DropdownSelector",
"required": true,
"type": "string",
"x-ms-summary": "Dropdown Selector",
"x-ms-dynamic-values": {
"operationId": "MyList",
"value-collection": "list",
"value-path": "ID",
"value-title": "Name",
"parameters": {
"Filter": {
"parameter": ""
}
}
}
}
],
"responses": {
"200": {
"description": "default",
"schema": {
"properties": {
"Selected ID": {
"description": "Selected ID",
"type": "string"
},
"Selected Name": {
"description": "Selected Name",
"type": "string"
}
},
"type": "object"
}
}
},
"summary": "Select from dropdown"
}
},
Here is the action that the list can get it's values from:
"/MyFlow/MyList": {
"post": {
"responses": {
"default": {
"description": "default",
"schema": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"type": "object",
"properties": {
"Name": {
"type": "string",
"description": "Name"
},
"ID": {
"type": "string",
"description": "ID"
}
}
},
"description": "list"
}
}
}
}
},
"summary": "My List",
"description": "My List Description",
"operationId": "MyList",
"parameters": [
{
"name": "body",
"in": "body",
"required": false,
"schema": {
"type": "object",
"properties": {
"Filter": {
"type": "string",
"description": "Filter"
}
},
"required": [
]
}
}
]
}
}
The results for my list come back in this format and I have checked and it is correct:
{
"list": [
{
"Name": "Hello world",
"ID": "1"
}
]
}
Seem like everything is setup correctly, but it always show a blank dropdown, what am I doing wrong or missing?
Turns out my input parameter for the action to get API is incorrect. I'll leave this question here for future references.