I'm trying to use RAML to describe following API call
PUT /api/v1/kv_store?{key}={value}
It's a simple key-value storage. I need to specify that key value can be any string, and API console should give users possibility to enter it as well as any other parameter.
Is it doable at all? I'm reading RAML 1.0 spec and can't find a way to do it, so small example will be really great.
Your are doing it completely wrong.
please read Documentation.
Correct way to implement QueryParameters by following code.
As this will cater your http://api/v1/kv_store/
/songs:
put:
queryParameters:
id: number
name: string
type: string
album: number
Related
I wanted to store a JSON in FHIR. JSON can be anything, for example, it can be something like
{
assignee: "PCC OFF SHORE",
dueby: "30-03-1991",
description: "This will be assigned to PCC off shoure"
}
You can store any arbitrary data as a Binary resource in an Attachment data type (e.g. DocumentReference or in an extension). Technically, you could also put it in a string data type, but that wouldn't be terribly appropriate as strings are not expected to be parseable.
Certain FHIR resources accept elements of type value[x]. That type accepts variations like valueString or valueCode. For your case, valueBase64Binary may be a good alternative.
Read: https://www.hl7.org/fhir/extensibility.html#extension
The google places api docs clearly state: "IMPORTANT: To avoid paying for data that you don't need, be sure to use Autocomplete.setFields() to specify only the place data that you will use." But then when I'm calling the getDetails() method (see in generic-y form below), I'm specifying my fields, which is what setFields() sets.
I THINK I'm basically setting them via the getDetails() method, but given the caution exercised in the docs, I also don't want to surprise anyone with extra costs besides what we need. I've tried to find a clear answer in the docs, but I haven't found one. I'm hoping someone here knows from experience or has better luck with the docs. Thanks!
const placesService = new google.maps.places.PlacesService(myField);
placesService.getDetails(
{
fields: ['address_components'],
placeId: result.place_id,
sessionToken: token,
},
details => this.updateMethod(details.address_components),
);
Autocomplete.setFields is used when implementing Places Autocomplete Widget which will constrain the succeeding Places Details request to specific fields only when a user selects a place from the suggestions. Check out the example here.
However, as for your given sample code, I can see that you are directly using Places Service to get the details of a place given a Place ID and not from the Autocomplete Widget suggestions. With this, you can just set the fields in the request parameter of the getDetails(request, callback) method which is what you have correctly done in your code. See this example.
Hope this helps!
I'm defining swagger definitions for an API and I came across this use case.
The request and the response object model definitions look exactly the same.
However, there is one field in the object which returns more enum values during the get operation but restricts to minimal enum values for the put operation. Is it possible to reference different enum values for the same field conditionally thus avoiding duplicate definitions. I do not want to recreate the entire model definitions for request and response for the sake of overcoming this limitation.
Here is my example,
definitions:
EntryRequest:
properties:
entries:
$ref: '#/definitions/EntityResponse/properties/entries'
EntryResponse:
properties:
entries:
type: array
items:
$ref: '#/definitions/Entry'
Entry:
properties:
entryStatus:
type: string
enum:
- ENABLE
- DISABLE
- IN_PROGRESS
In the above, there are two things that I'm worried about.
1) For EntryRequest, the API accepts only ENABLE/DISABLE for PUT operation while the API returns all of them in the GET operation. I would like to create a reference to the entryStatus property conditionally. Is it possible?
2) Also, everything except the entryStatus is same for both the EntryRequest and EntryResponse object model. I do not want to duplicate that as well for the sake of representing the differention of entryStatus field.
Is there a way to do it?
EDIT:
As I learn more on this, I get a feeling that this is more an yaml related query. But I would like to have it here to see if anyone has faced a similar situation and how they have handled it. Or to see if I get any recommendations on how to handle this.
For tagging different enums to the same field, I think I can do like this,
RequestEntryStatus:
type: string
enum: &requestStatus
- ENABLE
- DISABLE
ResponseEntryStatus:
type: string
enum: &responseStatus
- ENABLE
- DISABLE
- IN_PROGRESS
Entry:
properties:
entryStatus: *requestStatus
But still this would enforce me to create duplicates of request and response objects with different mapping to the entryStatus field. I would like to know if there is a better way to handle this.
The request and the response object model definitions look exactly the same. However, there is one field in the object which returns more enum values during the get operation but restricts to minimal enum values for the put operation. Is it possible to reference different enum values for the same field conditionally thus avoiding duplicate definitions. I do not want to recreate the entire model definitions for request and response for the sake of overcoming this limitation.
No, it's not possible.
If you want to avoid duplication, you can use a single model with all the enum values, but document verbally in the description that certain values are only used in the responses but not the requests.
I'm writing client-side code for an app that will query a GraphQL server. In a couple of places in my code, I'm passing around data that will eventually get turned into a query variable, so it needs to validate against a specific GraphQLInputType in my schema. On looking into some of the utilities that graphql-js provides, it looks like the isValidJSValue checker is exactly what I'm looking for, and its comments even mention that it's intended to be used to do just that.
The issue is that I don't have access to the GraphQL type I want to validate against as a JS object, which is what I'm pretty sure that function is looking for. I'm importing my schema (as an npm depdendency) as JSON, or I also have it in the schema notation. Is there some other utility I can use to get the JS type I need from one of those sources, and then use that to check my data with isValidJSValue? Or is there some other way I could go about this that I just haven't thought of?
You can use the JSON schema you have imported to construct an actual GraphQL schema instance using buildClientSchema here: https://github.com/graphql/graphql-js/blob/master/src/utilities/buildClientSchema.js
Then, it should be a simple matter of looking in the types field of the resulting schema to find your input type, and then calling isValidJSValue on it.
I'm curious, though - why validate the value on the client before sending it, rather than just relying on the validation the server will do?
I'd like to be able to document the parameters as if they were URL parameters, since I like how that bit of documentation renders a handy table. However, in my API, I would like those paremeters to plug into the JSON body rather than the URL. Is there a way to achieve this?
The dedicated syntax for describing, discussing (and thus also validating) message-body is in the making.
It will be based on the Markdown Syntax for Object Notation, similar to the actual URI Parameters description syntax (eventually these two should converge).
Also see related How to specify an optional element for a json request object and Is it possible to document what JSON response fields are? questions.