Support for POST parameters in RAML

I would like to ask if there is support for POST parameters in RAML . And if so, what is the syntax. I looked at spec 0.8 and spec 1.0 roughly (in fact, I am tied to 0.8 , as many tools do not yet support 1.0 ). I did not find support for POST options, but maybe I missed something.

So what can I say about POST parameters? This can be one of two (sorry, I do not know their official names, if any):

  • Simple HTTP parameters, key=value , each parameter in one line, for example

    name=John Doe amount=5 , which is not very convenient (for example, there is no nesting)

  • as a JSON object, only JSON with all its syntax is allowed (the server side must parse this json); eg:

    {"name":"John Doe","amount":"5"}

Various server-side API implementations use either 1st or 2nd. Anyway, how does RAML support?

+6
source share
3 answers

@Pedro considered option 2, so here is option 1. Based on the discussion in the comments, it seems that the encoding used is application/x-www-form-urlencoded .

You need to use formParameters .

Example:

  post: description: The POST operation adds an object to a specified bucket using HTML forms. body: application/x-www-form-urlencoded: formParameters: AWSAccessKeyId: description: The AWS Access Key ID of the owner of the bucket who grants an Anonymous user access for a request that satisfies the set of constraints in the Policy. type: string acl: description: Specifies an Amazon S3 access control list. If an invalid access control list is specified, an error is generated. type: string 

Link: https://github.com/raml-org/raml-spec/blob/master/raml-0.8.md#web-forms

+6
source

As shown in this link https://github.com/raml-org/raml-spec/wiki/Breaking-Changes :

For ramp 0.8:

 body: application/x-www-form-urlencoded: formParameters: name: description: name on account type: string example: Naruto Uzumaki gender: enum: ["male", "female"] 

Equivalent to raml 1.0 for:

 body: application/x-www-form-urlencoded: properties: name: description: name on account type: string example: Naruto Uzumaki gender: enum: ["male", "female"] 

So this changes, this is the formParameters attribute for the one properties.

+7
source

Message parameters can be expressed using JSON Schema

A simple example of RAML 0.8:

 #%RAML 0.8 title: Api baseUri: / schemas: - Invoice: | { "$schema": "http://json-schema.org/draft-03/schema", "type": "object", "properties": { "Id": { "type": "integer"}, "Name": { "type": "string"}, "Total": { "type": "number"} } } /invoices: post: body: application/json: schema: Invoice 
+4
source

All Articles