rramanadham
6 years agoNew Contributor
swagger schema to have a property whose value is concatenation of a string and a property value
1. I have my body schema as below. How can I use the value of type property in my eventName property?
2. what's the best way to set the audit value to true in the schema
"refreshSchema": {
"type": "object",
"properties": {
"sourceTns": {"type": "string"},
"backupDate": {"type": "string"},
"type": {"type": "string","enum":["CMP_BUILD","STANDARD","CMP_UPGRADE_TRIAL","CMP_UPGRADE_CUTOVER"]},
"audit": {"type": "boolean","default":true},
"auditEventName": {"type": "string","default":"Create refresh of type -{type}"}
},
"required": [
"sourceTns",
"backupDate",
"type"
],
"additionalProperties": false
}
I want the object with values to be like this -
"sourceTns" : "abcd",
"backupDate": "latest",
"type":"CMP_BUILD",
"audit": true,
"auditEventName":"Create refresh of type - CMP_BUILD"
1. OpenAPI Specification does not have a way to define dynamic/computed values. These values will have to be computed by the sender of the data.
2. Your example is correct, but if you mean that "audit" is always true use an enum instead:
"audit": {"type": "boolean", "enum" [true]},
There's no real way of enforcing that in the spec.