cancel
Showing results for 
Search instead for 
Did you mean: 

swagger schema to have a property whose value is concatenation of a string and a property value

SOLVED
New 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"

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Moderator

Re: swagger schema to have a property whose value is concatenation of a string and a property value

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]},

Helen Kosova
SmartBear Technical Writer
________________________
Vote up helpful replies.
Accept this reply if you think it's the best solution to your question.

Join the September Hub-bub to show off, learn and win
Moderator

Re: swagger schema to have a property whose value is concatenation of a string and a property value

There's no real way of enforcing that in the spec.

3 REPLIES 3
Moderator

Re: swagger schema to have a property whose value is concatenation of a string and a property value

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]},

Helen Kosova
SmartBear Technical Writer
________________________
Vote up helpful replies.
Accept this reply if you think it's the best solution to your question.

Join the September Hub-bub to show off, learn and win
Moderator

Re: swagger schema to have a property whose value is concatenation of a string and a property value

There's no real way of enforcing that in the spec.

Highlighted
New Contributor

Re: swagger schema to have a property whose value is concatenation of a string and a property value

Thank you for the clarification

New Here?
Join us and watch the welcome video:
Join our online event
SeptemberHubBub
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win