-
Notifications
You must be signed in to change notification settings - Fork 180
Ability to select a particular sample of a referenced name type #24
Comments
This is something we have been thinking about but the MSON feature is still in beta and we would like to finish supporting it first. |
Sounds good! Just wanted to get it on your radar. I think it will become an important feature over time, as people start using Apiary for emulating different sample outputs using the "Prefer" header (which I think it's a very powerful feature). Developers using the "Prefer" header in combination with complex (e.g., nested) objects won't be able to use MSON because of the limitation I've documented in this issue (the alternative would be having different Named Types for each sample, which defeats the purpose of using MSON) |
This is definitely planned for a future release of the parser. As for the referencing one sample from another – I do not really see a use as for it. Maybe an example would help? Note, in MSON, there is nothing like type definition and instantiation – those two are essentially a the same. Isn't something like: # Data Structures
## A (object)
+ a1: 1
+ a2: 2
# Resource A [/a]
## Create [GET]
+ request (application/json)
+ attributes (A)
+ response 201
+ request (application/json)
+ attributes (A)
+ a2: 42
+ response 400 working for you? Note this is related to apiaryio/api-blueprint#58 (when it comes to specifying what is a response based on input properties) |
I see... so you basically try to instantiate the attributes at the FORMAT: 1A
HOST: http://parametrizedmson.apiblueprint.org/
# Testing parametrized MSON
Just testing parametrized MSON.
# Resource A [/a]
## Create [GET]
+ request (application/json)
+ attributes (A)
+ response 201
+ request (application/json)
+ attributes (A)
+ a2: 42
+ response 400
# Data Structures
## A (object)
+ a1: 1
+ a2: 2 Comments and questions:
# Data Structures
## Item (object)
### Properties
- uuid: `08ff7052-2e95-11e3-a1fc-000c294eede0` (required, string, sample) - A unique ID
- property1: 42
- property2: 56
## Collection (object)
### Properties
- data (object, required, sample)
- currentItemCount: `1` (required, number, sample) - Number of items in the current view of the collection
- totalItems: `1` (required, number, sample) - Number of total items in the collection
- items (array[Item])
|
Hey @jmdacruz Regarding the |
Great to now! Thanks! |
@pksunkara is there a tracking issue for the "a: 42 not overriding the a: 2" ? |
hmm... Looks like we don't have a tracking issue for it. |
@pksunkara so please create one or turn this one into it (but preferably the former and on the parser). Thanks! |
If we do not have a tracking issue then it is not a know issue :) |
thanks @pksunkara |
Just to reiterate. Is there another issue but the fix of apiaryio/drafter#44 . @jmdacruz are we looking for a way to display different samples in libraries using MSON or are we asking parser – representation renderer to render specific sample instead of the default one? |
From what I understood, @jmdacruz was talking about having a way to select a specific sample to be sent the to the renderer in certain cases instead of the default one. Example (disregard the syntax): We have a named type + (array)
+ (User:pavan)
+ (User:kyle) should render the following: [
{
"username": "pavan"
},
{
"username": "kyle"
}
] |
@zdne can you elaborate on the difference between these two alternatives?
|
I recently found myself in the following situation: I defined a couple of Named Type objects, one referencing the other(e.g., object A has a reference to object B). Each of the objects may have a couple of Sample sections. I'd like to have the ability, when defining the Sample section of object A, to reference a particular Sample in object B's definition. This would allow me to document difference scenarios of the API.
Moreover, I'd like to see Samples that are just instantiations of the type definitions, or that are somehow validated against the type definition (in order to avoid inconsistencies between samples and the type definition)
The text was updated successfully, but these errors were encountered: