JSON Schema, resource "id" attribute handling


#1

Hi all,

I have a Resource called “User” for example, so in my REST API I have the following

GET /users (Get all users)
GET /users/{id} (get a specific user)
POST /users (Add a user to the collection)

The issue I have is that I need three schema’s for the above.

First one for the users collection.
Second one for the user. “id” attribute is mandatory here.
Third one for the create user, here the only difference in the body of the request i don’t supply the “id” attribute. “id” attribute is optional here.

How do others handle this. I want to get to a stage where by I auto-generate my POJO’s, but at the moment this is an open question for me.

Regards,
Cormac


#2

Do you mean how to design that with a JSON schema or using RAML data types?