Closed pratikmallya closed 4 years ago
not 100% clear what you want. A REST GET verb always has a single id
it sounds like you want a MULTIGET. this always returns a collection, and is most commonly known as a query. to effect this, put "query" after nitro and add the verb MULTIGET.
this is all covered in RFC API-3 and also the reference guide on github for reslang
not 100% clear what you want.
I would like the response from GET to be described accurately. In the example, the response is described as:
v0-carsOutput:
type: object
properties:
id:
description: ''
type: string
make:
description: ''
type: string
nitro:
description: ''
type: string
required:
- id
- make
which is saying that the id
and make
attributes are required in the response, while the response from GET must return all 3 attributes. i.e all 3 attributes are required. Does that clarify the ask?
A REST GET verb always has a single id
I don't believe I said anywhere that it doesn't.
it sounds like you want a MULTIGET. this always returns a collection, and is most commonly known as a query. to effect this, put "query" after nitro and add the verb MULTIGET.
Nope, I want to GET
a single resource, not multiple resources so the MULTIGET is not relevant.
ah, apologies, i misunderstood.
i've reworked the way attributes are marked as included for a given set of verbs and whether they are optional or not. please see the reference manual here under "Attribute modifiers" for more info: https://github.com/LiveRamp/reslang/blob/master/docs/reference.md
Here's a simple example:
configuration-resource Car {
id: string
make: string
nitro: string mutable optional-post
created: datetime output
location: string mutable optional-put
/operations
GET POST PUT PATCH
}
This results in the following fields:
POST required=make and location, optional=nitro PUT required=nitro, optional=location PATCH optional=nitro and location GET required=id, make, nitro, created, location
The underlying intuition is that you mark fields are mutable if you want to be able to change them with PUT or PATCH, and you can mark something as output only by using "output".
You can then mark things as optional by using "optional" or "optional-post" etc for specific verbs. PATCH always has every field as optional.
Please let me know if this is not sufficient by providing an example and also re-opening this issue.
Commit: https://github.com/LiveRamp/reslang/commit/7047ee601a15d462318f68638c8e1172f2e8d7bb
When describing the results on
GET
endpoints for a resource:The generated swagger contains an object specification for a successful response to the
GET
request as:The
required
attribute is incorrectly generated. While thenitro
option for a car is an optional property whenPOST
ing a request, it is a required property when aGET
request is made to get a car, since a car's description must include whether or not it hasnitro
installed.Full Generated Swagger: