Add space in properties in RAML datatype which has json example as "First Name" : "John"


#1

I am not able to add space in properties in RAML 1.0 datatypes. Like

#%RAML 1.0 DataType

type: object
properties:
first name: ##??
required: false
type: string
example: |
{
“first name” : “johhny”
}


#2

I tried this in api-workbench and got “keys should not have spaces”. I have to admit I was suprised because JSON accepts the following and it would not be possible to represent.

{
	"property name": "value"
}

#3

It’s a valid JSON object, well it’s a bad practice but there should be some way to handle it in RAML 1.0


#4

What are you using to validate your fragment @Tushar_Sagar?


#5

@christian_vogel I am using json schema to validate the fragment


#6

I would probably use an official RAML parser, like the JS parser, for this. But changing the fragment to the following works for me.

#%RAML 1.0 DataType

type: object
properties:
  'first name': ##??
    required: false
    type: string
example: |
  {
    "first name" : "johhny"
  } 

BUT, I would not recommend using spaces in property names! There isn’t any need for that.