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
Highlighted
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
Highlighted
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 Documentation Team Lead
________________________
Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today

View solution in original post

Highlighted
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.


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

3 REPLIES 3
Highlighted
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 Documentation Team Lead
________________________
Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today

View solution in original post

Highlighted
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.


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓

View solution in original post

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:
Top Kudoed Authors