Is it possible to create duplicate key in swagger?.
or
Basically i need to create duplicate key in schema reference definition of the swagger so that it can come as a default value in the payload of Developer Portal of SmartDoc.
We are struggling to create the the Swagger file which can meet our requirement, Any kind of help is appreciated.
anilsr
August 10, 2017, 5:21am
2
@Ankit Dwivedi , What do you mean “duplicate key” ? can you give an example ?
Hi @Ankit Dwivedi
I am not sure what you mean by duplicate key.
For default value you can try using the default property as following.
Category:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
default: "cat"
Hi @Anil Sagar
Duplicate key means like i have shown in below image:
Here we are giving default value in the schema Ref-faultCharacteristics.
and here we have
type: object whcih have default value: troubleCode
type: object whcih have default value: WestDide
So how we can have multiple attribute with same name in Schema definition?
Note:DK mean duplicate key
And we want it to be like the below image , is it possible to have multiple value. in requeat body of schema??
Hi @snehal chakraborty
i am doing that but i need multiple default value for “type” and “name” in like:
Category:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
default: "cat"
id:
type: "Float"
format: "int64"
name:
type: "string"
default: "Dog"
Like this…
anilsr
August 10, 2017, 9:33am
6
@Ankit Dwivedi
I don’t think it’s a valid json, Either you go for array format or have different names. The names within an object SHOULD be unique .
@Ankit Dwivedi
The yaml structure you mentioned is incorrect. each property has to be unique. I am not able to understand your requirement, but have a feeling that you want to enumerate possible values for a field. It can be done like this
Category:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
enum:
- cat
- dog
@Anil Sagar
Yes the that what i want to confirm that can we create multiple object in Array or in any other way as i need
thanks for clearing this
thanks @snehal chakraborty thats what want to understand , The requirement is i want to create object that can have same “name/value pairs” in swagger(where we define default value in schema)
Like below mentioned
“faultCharacteristics”: [{
“type”: “TroubleCode”,
“value”: “ULL”
},
{
“type”: “Workable”,
“value”: “No”
},
{
“type”: “AssociateOutage”,
“value”: “No”
},
{
“type”: “ServiceNeverWorked?”,
“value”: “No”
}]
@Ankit Dwivedi
Try this
faultCharacteristic:
type: object
properties:
type:
type: string
description: >-
Used to identify the problem faced by the service. Possible values
TroubleCode, Workable, AssociateOutage, ACVoltage, OpenIn,
ServiceNeverWorked, RequestedTask, DiagnosticTestId.
enum:
- TroubleCode
- Workable
- AssociateOutage
- ACVoltage
- OpenIn
- ServiceNeverWorked
- RequestedTask
- DiagnosticTestId
value:
type: string
description: >-
'Value of the identified parameter. Possible values are based on the
type. TroubleCode NSY 'Workable : Yes/No' 'AssociateOutage: Yes/No'
'ACVoltage: Yes/No' 'OpenIn: Yes/No' 'ServiceNeverWorked: Yes/No'
'RequestedTask: Appointment/Commitment/Tester' 'DiagnosticTestId:
107828' 'Trouble Code listed is example code only.
[https://sdev.telstra](https://sdev.telstra).
com/content/trouble-ticket-api-supporting-materials#TW Create Input
Guidelines'.
enum:
- Yes
- No
- Appointment
- Commitment
- Tester
faults:
type: object
properties:
faultCharacteristics:
type: array
items:
$ref:'#/definitions/faultCharacteristic'