Defining identical HTTP verbs without duplication?


#1

Hello

I document my Api and have come upon an endpoint with 2 http verbs - POST and PUT - that are identical - same body,same examples. Do I have to copy the definition for POST and paste so I end up with duplicate definitions or can I somehow declare in Raml that POST and PUT use the same definition?

Thanks,

Marc


#2

As far as I know you would define them separately. However, you could put the common headers, body, responses, etc in separate inlined (or files) traits, resourceTypes, etc and then specify those in the two method declarations, making them much shorter.

Ideally however, although not enforced or incorrect the way you are doing it, I prefer to separate POST/PUT, where in my APIs POST is a create, where as PUT would be an overwrite of the resource. Slightly different responses, potentially different error conditions.