cancel
Showing results for 
Search instead for 
Did you mean: 

Naming a property with a reserved keyword for name

SOLVED
New Contributor

Naming a property with a reserved keyword for name

Hi all,

 

I need to write a contract to act as a schema for the rest messages which a legacy system sends. Unfortunately this system uses 'type' as the name of a property. A relevant snipped of the JSON is here:

elements: [
{ type: "radiogroup",
name: "DentalQuestion2" }
,
{ type: "checkbox",
name: "DentalQuesiton3" }
]

 

I am defining the schema (for the elements inside the array) like this: 

 

components:  
  schemas:  
  element:  
  type: object 
  properties:  
    name:  
      type: string  #type here is the keyword
    type: #type here is the actual name of the property!
      type: string
        enum:
          - radiogroup
          - checkbox

However it appears the SwaggerHub validator is telling me this is incorrect. Is there any way to override the 'type' keyword?

Regards,

John

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Re: Naming a property with a reserved keyword for name

What error do you get?

 

The only issue I'm seeing here is there's a problem with the indentation, but that could be a pasting error. Once fixed, the editor is not giving me any errors.

2 REPLIES 2
Highlighted
Moderator

Re: Naming a property with a reserved keyword for name

What error do you get?

 

The only issue I'm seeing here is there's a problem with the indentation, but that could be a pasting error. Once fixed, the editor is not giving me any errors.

New Contributor

Re: Naming a property with a reserved keyword for name

Yes! you were right. Thanks.

New Here?
Join us and watch the welcome video:
API Testing Mistake #2
APITestingMistake#2