Developer Portal - Default value in SmartDoc for duplicate Key value

Not applicable

Hi I was trying to import swagger in Dev Portal but in our payload we have multiple attribute with same name:

 "faultCharacteristics": [{
                       "type": "TroubleCode",
                       "value": "ULL"
           },
           {
                       "type": "Workable",
                       "value": "No"
           },
           {
                       "type": "AssociateOutage",
                       "value": "No"
           }       
           ],
 

As of now when we import the swagger in Smart Doc of Dev Portal, it is having only one attribute pair :

faultCharacteristics:
    type: object
    properties:
      type:
        type: string
        default: TroubleCode
        description: >-
          Used to identify the problem faced by the service. Possible values
          TroubleCode, Workable, AssociateOutage, ACVoltage, OpenIn,
          ServiceNeverWorked, RequestedTask, DiagnosticTestId.
      value:
        type: string
        default: ULL
        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.
          com/content/trouble-ticket-api-supporting-materials#TW Create Input
          Guidelines'.

  • Is there any way we can include more type and value pair as you can see in above we have only one pair.
  • when we are tying to import other pair we are getting as "Duplicate Key error" in swagger online editor

Please suggest @yuriyl , @Anil Sagar , @Diego Zuluaga , @Gordon Rogers

0 2 206
2 REPLIES 2

Hi @Ankit Dwivedi

Change your spec like this

faultCharacteristics:
    type: object
    properties:
      type:
        type: string
        default: TroubleCode
        description: >-
          Used to identify the problem faced by the service. Possible values
          TroubleCode, Workable, AssociateOutage, ACVoltage, OpenIn,
          ServiceNeverWorked, RequestedTask, DiagnosticTestId.
      value:
        type: string
        default: ULL
        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.
          com/content/trouble-ticket-api-supporting-materials#TW Create Input
          Guidelines'.
faults:
  type: object
  properties: 
    faultCharacteristics:
       type: array
       items:
         $ref:'#/definitions/faultCharacteristics'

This should give you the desired result

Hi @snehal chakraborty thanks for replying .

Please can you elaborate your solution as i am not able to understand what we i have to.

Basically we want multiple default value :

 faultCharacteristics:
    type: array
    properties:
      type:
        items:
          type: string
          default: TroubleCode,
          description: >-
          Used to identify the problem faced by the service. Possible values
          TroubleCode, Workable, AssociateOutage, ACVoltage, OpenIn,
          ServiceNeverWorked, RequestedTask, DiagnosticTestId.
      value:
        type: string
        default: ULL
        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.
          com/content/trouble-ticket-api-supporting-materials#TW Create Input
          Guidelines'.
          type:
        items:
          type: string
          default: WorkForce,
          description: >-
          Used to identify the problem faced by the service. Possible values
          TroubleCode, Workable, AssociateOutage, ACVoltage, OpenIn,
          ServiceNeverWorked, RequestedTask, DiagnosticTestId.
      value:
        type: string
        default: NILL
        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.
          com/content/trouble-ticket-api-supporting-materials#TW Create Input
          Guidelines'.
  

Here you can see that we have 2 values of "type", so how can we achieve this without getting error "duplicated mapping key"

 type: string          
default: TroubleCode, and type: string default: WorkForce,