Forum Discussion

jms137's avatar
jms137
New Contributor
6 years ago
Solved

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

  • 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

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

    • jms137's avatar
      jms137
      New Contributor

      Yes! you were right. Thanks.