Skip to main content
Add "additionalProperties" constraint to clarify the need for this update in the first place
Source Link
user92338
user92338

Let's say I have a users resource, with two properties: name and email as specified by a users JSON Schema document, which right now looks like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "name": {
      "type": "string"
    },
    "email": {
      "type": "string"
    }
  },
  "required": [
    "name",
    "email"
  ]
}

My requirements state that we need to be able to change the schema, e.g. to add a property such as phoneNumber, and do so via HTTP in a RESTful way. That is, I need to be able to update the JSON Schema definition of the users resource to look like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "name": {
      "type": "string"
    },
    "email": {
      "type": "string"
    },
    "phoneNumber": {
      "type": "string"
    }
  },
  "required": [
    "name",
    "email",
    "phoneNumber"
  ]
}

Now, clients of the API can create new users that have the additional phoneNumber property (where previously I would have gotten a schema validation error).

I am puzzling over how to do this. One way I can imagine doing it is by creating a "meta-resource" called resources. This resource might have some properties, for example: path and schema. The schema property would be a full JSON Schema object. To update the users resource, then, I could maybe POST to resources with an HTTP request body like:

{
    "path": "users",
    "schema": { ...JSON Schema object goes here... }
}

Is this a reasonable implementation? If not, why not? Alternative ideas? Any pitfalls I should watch out for? Any articles/blogs on this topic that I should read? (I haven't been able to Google successfully for this).

Let's say I have a users resource, with two properties: name and email as specified by a users JSON Schema document, which right now looks like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "email": {
      "type": "string"
    }
  },
  "required": [
    "name",
    "email"
  ]
}

My requirements state that we need to be able to change the schema, e.g. to add a property such as phoneNumber, and do so via HTTP in a RESTful way. That is, I need to be able to update the JSON Schema definition of the users resource to look like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "email": {
      "type": "string"
    },
    "phoneNumber": {
      "type": "string"
    }
  },
  "required": [
    "name",
    "email",
    "phoneNumber"
  ]
}

Now, clients of the API can create new users that have the additional phoneNumber property (where previously I would have gotten a schema validation error).

I am puzzling over how to do this. One way I can imagine doing it is by creating a "meta-resource" called resources. This resource might have some properties, for example: path and schema. The schema property would be a full JSON Schema object. To update the users resource, then, I could maybe POST to resources with an HTTP request body like:

{
    "path": "users",
    "schema": { ...JSON Schema object goes here... }
}

Is this a reasonable implementation? If not, why not? Alternative ideas? Any pitfalls I should watch out for? Any articles/blogs on this topic that I should read? (I haven't been able to Google successfully for this).

Let's say I have a users resource, with two properties: name and email as specified by a users JSON Schema document, which right now looks like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "name": {
      "type": "string"
    },
    "email": {
      "type": "string"
    }
  },
  "required": [
    "name",
    "email"
  ]
}

My requirements state that we need to be able to change the schema, e.g. to add a property such as phoneNumber, and do so via HTTP in a RESTful way. That is, I need to be able to update the JSON Schema definition of the users resource to look like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "name": {
      "type": "string"
    },
    "email": {
      "type": "string"
    },
    "phoneNumber": {
      "type": "string"
    }
  },
  "required": [
    "name",
    "email",
    "phoneNumber"
  ]
}

Now, clients of the API can create new users that have the additional phoneNumber property (where previously I would have gotten a schema validation error).

I am puzzling over how to do this. One way I can imagine doing it is by creating a "meta-resource" called resources. This resource might have some properties, for example: path and schema. The schema property would be a full JSON Schema object. To update the users resource, then, I could maybe POST to resources with an HTTP request body like:

{
    "path": "users",
    "schema": { ...JSON Schema object goes here... }
}

Is this a reasonable implementation? If not, why not? Alternative ideas? Any pitfalls I should watch out for? Any articles/blogs on this topic that I should read? (I haven't been able to Google successfully for this).

clarify the question and include example schemas
Source Link
user92338
user92338

Let's say I have a users resource, with two properties: name and email as specified by a users JSON Schema document., which right now looks like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "email": {
      "type": "string"
    }
  },
  "required": [
    "name",
    "email"
  ]
}

My client wantsrequirements state that we need to be able to change the schema, e.g. to add a property, such as phoneNumber, and they want to be able to do itso via HTTP in a RESTful way. That is, I need to be able to update the JSON Schema definition of the users resource to look like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "email": {
      "type": "string"
    },
    "phoneNumber": {
      "type": "string"
    }
  },
  "required": [
    "name",
    "email",
    "phoneNumber"
  ]
}

Now, clients of the API can create new users that have the additional phoneNumber property (where previously I would have gotten a schema validation error).

I am puzzling over how to do this. One way I can imagine doing it is by creating a "meta-resource" called resources. This resource might have some properties, for example: path and schema. The schema property would be a full JSON Schema object. To update the users resource, then, I could maybe POST to resources with an HTTP request body like:

{
    "path": "users",
    "schema": { ...JSON Schema object goes here... }
}

Is this a reasonable implementation? If not, why not? Alternative ideas? Any pitfalls I should watch out for? Any articles/blogs on this topic that I should read? (I haven't been able to Google successfully for this).

Let's say I have a users resource, with two properties: name and email as specified by a users JSON Schema document. My client wants to add a property, phoneNumber, and they want to be able to do it via HTTP in a RESTful way.

I am puzzling over how to do this. One way I can imagine doing it is by creating a "meta-resource" called resources. This resource might have some properties, for example: path and schema. The schema property would be a full JSON Schema object. To update the users resource, then, I could maybe POST to resources with an HTTP request body like:

{
    "path": "users",
    "schema": { ...JSON Schema object goes here... }
}

Is this a reasonable implementation? If not, why not? Alternative ideas? Any pitfalls I should watch out for? Any articles/blogs on this topic that I should read? (I haven't been able to Google successfully for this).

Let's say I have a users resource, with two properties: name and email as specified by a users JSON Schema document, which right now looks like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "email": {
      "type": "string"
    }
  },
  "required": [
    "name",
    "email"
  ]
}

My requirements state that we need to be able to change the schema, e.g. to add a property such as phoneNumber, and do so via HTTP in a RESTful way. That is, I need to be able to update the JSON Schema definition of the users resource to look like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "email": {
      "type": "string"
    },
    "phoneNumber": {
      "type": "string"
    }
  },
  "required": [
    "name",
    "email",
    "phoneNumber"
  ]
}

Now, clients of the API can create new users that have the additional phoneNumber property (where previously I would have gotten a schema validation error).

I am puzzling over how to do this. One way I can imagine doing it is by creating a "meta-resource" called resources. This resource might have some properties, for example: path and schema. The schema property would be a full JSON Schema object. To update the users resource, then, I could maybe POST to resources with an HTTP request body like:

{
    "path": "users",
    "schema": { ...JSON Schema object goes here... }
}

Is this a reasonable implementation? If not, why not? Alternative ideas? Any pitfalls I should watch out for? Any articles/blogs on this topic that I should read? (I haven't been able to Google successfully for this).

capitalize RESTful
Link
user92338
user92338

Define a restfulRESTful API for creating/updating other resource definitions?

Source Link
user92338
user92338
Loading