cancel
Showing results for 
Search instead for 
Did you mean: 
Welcome to the September Hub-bub

We are inviting you to join our exciting online event where you can learn a lot of useful information, share your knowledge and have fun. Each week, we will reward the best posters with free gift cards .

Just pick any topic you like in the SwaggerHub Community, or create your own to dive into the wonderful September Hub-bub.

Event duration: September 2-27. More information.

This Week Top Contributors:

We will decide the winners next Monday

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
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
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:
Top Kudoed Authors
Join the September Hub-bub to show off, learn and win