How to define the format a string Parameter must take? - apiblueprint

We have a querystring parameter called imageDimensions, which specifies the desired dimensions for images of different types.
e.g. ?imageDimensions=poster:600x800,badge:100x100
Is there a way in API Blueprint to specify that imageDimensions should be a comma-separated list of image dimension specs, each of form "(image type):(width)x(height)"?

There is no good dedicated syntax for it at the moment. I would probably go with something like:
## GET /resource{?imageDimensions}
+ Parameters
+ imageDimensions (string, optional) - Comma-separated list of image dimension specs, each of form `(image type):(width)x(height)`
Where the `(image type)` is one of the following:
- badge
- poster
- icon
+ Sample: `badge:100x100`
+ Sample: `poster:600x800`
+ Sample: `poster:600x800,badge:100x100`
+ Response 200
Note, it is planned to move the parameters syntax to full MSON syntax in the near future. See the API Blueprint roadmap.
With it, it should be possible to define types for images as an enum and then reference it in the blueprint.

Related

FHIR Observation DSTU2 resource

I need some help getting the value and unit of a result from the FHIR Observation DSTU2 resource. I want to map these values to strings but it looks like Observation.value[x] can have different type of data. Any thoughts on how to do this in C#? I tried a few ways but no luck so far because the sandbox I'm using contains results as strings, Quantity and CodeableConcept.
http://hl7.org/fhir/observation-definitions.html#Observation.value_x_
For the Observation.value field you indeed have a choice of type, so the data in the FHIR resource can hold any of the choices listed for that field.
If you use the Hl7.Fhir.Dstu2 library - the official C# reference implementation available through NuGet, you can use it to easily retrieve the resources from your sandbox and get them into a POCO. Here's an example:
using Hl7.Fhir.Model;
using Hl7.Fhir.Rest;
var client = new FhirClient("<your sandbox url>");
var obs = client.Read<Observation>("Observation/<technical id>");
// now you can access obs.Value regardless of the type in it
if you need to serialize the data to xml or json, you use the serializer:
using Hl7.Fhir.Serialization;
var serializer = new FhirJsonSerializer();
Console.WriteLine(serializer.SerializeToString(obs));

UFT: Problem in extracting data from excel file and input in the application dynamically

I am facing issues in performing certain actions based on the value in the excel file cell data.
Actions like if value is "NORMAL" then click Container type = Normal (radio button)
Similarly the Unit Container Value
Following is my code:
I am getting this error while performing action .WebElement("Container_Type_Normal").Click
Your error is because you can't start a line with . unless your within a with - and i can't see a with in your function. (i also don't recommend using a with as the can cause needless confusion)
The .webelement object is a catch-all type of object that is the child of other web objects or .page. You need this to be a full and valid path to the object, by this i mean start with browser().page().
You have a couple of options:
You can either make this a full path to your object based on the object repository:
Browser("<<OR Browser name>>").Page("<<OR Page name>>").WebElement("<<Your webelement name>>".click
For this, look at your OR and insert your names.
Or, option 2, you can use descriptive programming:
Browser("CreationTime:=0").Page("index:=0").WebElement("text:=" & fieldValue,"index:=0").click
That will take the browser that was created first (Creation time 0), the only page it has and the first (index 0) web element that contains your text (text is field value).
I'm assuming that you only have one browser, and that the first element that contains the text you want is what you want to click. You may need to add more layers too this or
A good approach is to mirror what is OR or use the object spy to ensure these properties are correct.

Repeating a MSON data structure with different values

I have many places in my API where I will need to describe a list of objects. Each object has the same keys / structure but different values. How can I tweak the values of each instance of some data structure while retaining all the original type, description, etc of the original structure?
for example if I had the following data structure Restaurant
# Data Structures
## Restaurant (object)
+ restaurant_name: McDonald's (string, required) - The name of this restaurant
+ years_of_operation: 54 (number, required) - The number of years since established
Then, let's say I want to instantiate several Restaurants in a GET response like so:
### List all restaurants [GET /restaurants]
+ Response 200 (application/json)
+ Attributes
+ data (array)
+ (Restaurant)
+ (Restaurant)
+ restaurant_name: Bob Evans
+ years_of_operation: 23
+ (Restaurant)
+ restaurant_name: Eataly
+ years_of_operation: 16
the JSON body would look like this (note how years_of_operation for Bob Evans and Eatly are now numbers)
and the rendered documentation will only show this (the descriptions for restaurant_name and years_of_operation for Bob Evans and Eatly are now missing)
I thought that MSON would carry over those descriptions and type definitions. Otherwise, I have to update a description (or type, requirement, etc) everywhere that data structure is used... but I was under the impression this is a sort of problem MSON is supposed to solve? Am I doing something silly?
I'm posting here in addition to my github issue since it's been a long time since that repo has had contribution

How To Show Nested Attribute Definition In Apiary.io

I have a data structure defined as follows:
# Data Structures
## PlayerRank (object)
Represents the minimum amount of data the the client needs to send to give rank information about a particular Player in a particular Played Game.
+ playerId (number, required) - NemeStats unique identifier for the Player.
+ gameRank (number, required) - The corresponding rank of the Player in this Played Game. A rank of 1 means the Player got first place, 2 means second place, and so on.
+ pointsScored (number, optional) - Integer number of points the Player scored in the Played Game.
I'm attempting to use this data structure in another action definition as follows:
## Create a new Played Game [POST]
This service will record a new Played Game.
+ Attributes
+ gameDefinitionId (number, required) - NemeStats unique identifier for the Game Definition (e.g. Race For the Galaxy's unique Id) of the Played Game.
+ datePlayed (string, optional) - The date the game was played in yyyy-MM-dd format (e.g. 2015-04-29).
+ notes (string, optional) - Any notes or comments that the User wants to record about the game for future reference.
+ playerRanks (array[PlayerRank], required) - A collection of PlayerRank objects specifying the game rank and points scored for each Player. See below table for details.
What I want to happen is for the Apiary.io Documentation to show the definition of not only the top level attributes but also those of the PlayerRank object. As a developer trying to understand the UI, I want to see the definition of each object and field so I know how to properly form a request. Right now it only gives the description for the playerRanks object which is : "A collection of PlayerRank objects specifying the game rank and points scored for each Player." but it doesn't expand the definition to show all of the properties of a PlayerRank data structure.
Any idea if the Apiary.io documentation can facilitate this?
now Apiary, API Blueprint supports nested objects which you can define as below for example
+ Attributes (object)
+ name: iPhone 6 / 6s (string, required) - Offer Name
+ price: 10.4 (number) - Offer price
can be a number with 2 decimal places, this is the sale price
+ offer_options (object)
+ option_name: black (string, required) - offer option name
+ max_qty: 0 (number) - Purchase limit to this quantity
AFAIK it's a beta feature and the UI is not finished yet, see this github issue for more information and sneak preview of the birght future.

Data abstraction in API Blueprint + Aglio?

Reading the API Blueprint specification, it seems set up to allow one to specify 'Data Structures' like:
Address
street: 100 Main Str. (string) - street address
zip: 77777-7777 (string) - zip / postal code
...
Customer:
handle: mrchirpy (string)
address: (address)
And then in the model, make a reference to the data structure:
Model
[Customer][]
It seems all set up that by referencing the data structure it should generate documentation and examples in-line with the end points.
However, I can't seem to get it to work, nor can I find examples using "fully normalized data abstraction". I want to define my data structures once, and then reference everywhere. It seems like it might be a problem with the tooling, specifically I'm using aglio as the rendering agent.
It seems like all this would be top of the fold type stuff so I'm confused and wondering if I'm missing something or making the wrong assumptions about what's possible here.
#zanerock, I'm the author of Aglio. The data structure support that you mention is a part of MSON, which was recently added as a feature to API Blueprint to describe data structures / schemas. Aglio has not yet been updated to support this, but I do plan on adding the feature.

Resources