how to define the intra-dependencies within JSON elements?
how to define the intra-dependencies within JSON elements?
Let's say I have the following JSON which defines an API:
{"contract_name": "create_user",
"method": "POST",
"url": "/users",
"request_body": {
"username": {
"type": "email",
"options": "None",
"required": "true",
"unique":"true"
},
"role": {
"type": "string",
"options": [
"TESTER",
"RA_DEVICE"
],
"required": "true"
},
"userProfile": {
"type": "object",
"options": {
"TESTER": {
"firstName": {
"type": "string",
"options": "None",
"required": "true"
},
"lastName": {
"type": "string",
"options": "None",
"required": "true"
}
},
"RA_DEVICE": {
"deviceId": {
"type": "long",
"options": "None",
"required": "true",
"unique":"true"
}
}}
}
Now let's say I want to create API test-cases from generic python script(which can take any API definition and generate test-cases for it with some random values of 'type' of the element).
Problem: I want to define a condition between 'userProfile' and 'role' such that the 'userProfile' value should be based on the value of 'role'.
i.e. if my python script chooses "RA_DEVICE" as role then the value of
'userProfile' should correspond to "RA_DEVICE" in its options to be a random number representing 'deviceId'.
Kindly suggest a way to define relationship between 'role' and 'userProfile' with consideration that my python script to generate test-cases is to be generic(can generate test-cases for any API having intra-element dependencies).
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.