0

I have a large model which I am using for both GET and PUT on a resource. The model includes an "audit" object like so:

            "audit": {
                "createdAt": "2014-04-14T02:15:15Z",
                "lastUpdatedAt": "2014-04-14T02:15:15Z",
                "deletedAt": ""
            }

This is obviously a readonly part of the resource - is there any way to show this in the contract model so "audit" appears for the GET response representation but not the PUT request representation?

The only alternative I can see is to copy the model into the body of the PUT and remove the readonly parts - but that then eliminates the benefit of having a single model that is reusable across different methods.

Honza Javorek
  • 8,566
  • 8
  • 47
  • 66
Justin
  • 227
  • 2
  • 8

1 Answers1

1

This is not possible yet. Capabilities of current resource model are very limited. It's similar issue as Apiary: Refer to multiple models in a body or Reuse a resource model as an array.

There are plans to address this need and make blueprints more DRY in the future - See the Embedded Assets and Traits milestones.

Solution is to either copy & paste, or, in your particular case, not to return different payloads in GET and PUT. Why are you doing it?

Honza Javorek
  • 8,566
  • 8
  • 47
  • 66
  • > Why are you doing it? it doesn't make sense to include the "audit" object in the *request* representation for PUT. the response would include the audit object but not the request. – Justin Jul 02 '14 at 20:32