-
Notifications
You must be signed in to change notification settings - Fork 2.1k
External assets #20
Comments
I'm interested in this capability, and would ideally like it added sooner rather than later. Our particular use case is for documenting APIs where the request and response bodies are binary structures produced by Apache Avro. For these requests/responses, we'd like to be able to have the "Schema" be a link to either the Avro schema definition file, or a generated HTML document describing said Avro schema. It might look something like this: ## POST /myresource
Creates a new myresource.
+ Request (application/vnd.example.myresource+avro)
+ Schema:
[MyResource.avsc](http://docs.example.com/avro/myresource.avsc)
+ Response 201 (application/vnd.example.myresource+avro)
+ Schema:
[MyResource.avsc](http://docs.example.com/avro/myresource.avsc) |
👍 |
@mhurne @davidmc24 Have you thought about representation of this feature in the AST? Would you like to see hyperlink in the AST or blueprint parser should be capable to fetch target url and embed its content to the AST? |
My expectation is that the AST would contain the hyperlink, not the content of said hyperlink. It might be useful for the AST to "know" that it's a hyperlink as opposed to direct content, so that links can be produced in HTML documentation, for example. In cases where you've chosen to externalize the schema from the API, it's likely because either the schema is too large to make sense to inline in the API documentation, the schema is used by multiple APIs and has its own authoritative documentation, or the schema is a format which isn't appropriate for embedding. While those examples are schema-specific, I expect similar reasons apply to other payload types. |
I do like it. If it would be just the hyperlink it would be probably fairly easy to implement in the parser. The bigger challenge however comes with the needed change to the AST and its media-types Probably to something like this: {
"name": "<name>",
"description": "<description>",
"headers": {
"<header>": {
"value": "<header value>"
}
},
"body": {
"content": "<body>",
"href": "<uri>"
},
"schema": {
"content": "<schema>",
"href": "<uri>"
}
} |
Yep, that's exactly the AST I was considering. |
Additionally add additional syntax for external assets to be embedded (not just referenced-linked) by the
or
Alternatively using the Mardkown implicit link name:
or
|
Hello, |
Markdown is an uncomfortably loosely coupled family of mostly compatible extensions, so I'm not sure, but the only case I can think of where a link-like syntax actually means "embed not reference" is the image syntax (using a ! sigil): |
Good point @jrep !
That is my goal. According to Gruber's following should achieve the same goal:
Where I guess my point with
Should be
where the lablel is the actual URL, so proper full definition (so the markdown renders correctly) would be:
Now it would be obviously tedious to write:
Question is – should this (defining the label) be implicitly assumed by the parser? Or should we just ask blueprint writers to use the |
Couldn't we just use the alt/label part for actually describing what the asset is so the link is human-readable? Writing something like If someone wants to bypass this and ignore the best practise of describing assets this way, she can always put a dummy text there (such as already mentioned I used the |
I feel we should just support markdown with the extra sigil regardless of the syntax used – be it direct link, explicit or implicit label. If we agree on this only two questions remain:
is dup as well because most often than not you will use it in a schema section of a e.g.:
Thoughts? |
I'm all for supporting all of the standard variants, but this:
... is not how I understand Gruber's definition. Rather, I agree with honzajavorek: the stuff in the first [] is in some way a human-readable tag, not a redundant and tiresome duplicate of the link text. So, while it seems to be syntactically valid to include a path there, it's (a) weird, and (b) unhelpful. If the intent is "any Gruber-valid link form, with a new sigil," then I like that semantic but suggest a less surprising example (of the sort honzajavorek and I have suggested). |
@jrep @honzajavorek I agree. |
I think its difficult to compare inclusion of assets to existing pattenrs for either images or links. Isn't it actually combination of those two together? The problem with image syntax analogy is that in the world of images, alt texts are important, they're usually not duplicate in given context and nobody wants to actually write But assets don't necessarily need alt texts, that's true. As @zdne mentioned, they'll be always used in such context that it'll be totally clear what's going on here. I agree with that. The problem is, the only analogy to that I can think of are links without labels:
If we need something hybrid, let's call it "autolink syntax for images", and we want to adhere to Gruber as much as we can, we want something like following:
Again, using
to be rather cryptic for me as a reader and not following the reality of existing Markdown usage. I didn't even know about such possibility, I thought pairing has to be done by the second couple of brackets. (However, I am fully aware this last paragraph is very subjective). |
@zdne : as to the sigil: I don't much care, but the @zdne: I acknowledge that the most likely text
with
@honzajavorek: are you actually suggesting that Blueprint allow/mandate the string "/dev/null" in those places? Or was that just a place-holder? I never use "reference links," either, but I wouldn't object to Blueprint carrying them forward. |
@jrep I used Using links directly in section headers does not look bad at all, actually! Of course, it's just a first sight, I didn't really thought about what are the cons of such thing, but... at first sight it seems appealing to me. |
@jrep I like it. Taking it even further
|
The ability to split the file into separate files and then import them in would be very useful for long verbose API's. In the interm I manage my blueprint project with grunt. I use grunt-import and my Then all I do is run It takes 5 minutes to setup, but it makes life so much nicer! 👍 |
@alexborisov that is pretty neat! Thanks for the sharing. As I have said (elsewhere) – we have started the works on a parser harness tool that should take eventually care of this. Also, for what its worth, here is a script that composes multiple blueprints into one and publish it using the Apiary client gem https://gist.github.com/danvine/11087404 |
Also for what it's worth checkout @jamesramsay 's Hercule – https://github.com/jamesramsay/hercule |
Thanks @zdne for the mention. I had similar challenges when writing API documentation and we have been using Hercule internally for the last 3 months. Hercule uses a simple We have a number of API contexts for different types of API consumers that have nearly identical resources and we were keen to reduce duplication between the different documents. Thus, we have also extended this syntax to also support:
The |
I am just wondering why to use =[gist](gist.apib) or :[gist](gist.apib) it would work similarly, it would render reasonably as markdown, so you would be able to navigate through links, and you could use much richer syntax such as |
@zdne this is a really great suggestion! Too bad I didn't see this thread 6 months ago. The At the time I also looked at Marked app ( With the advantage of being able to click through the links when viewing the source documentation in Github and improved consistency with the feel of Markdown I've updated hercule to use |
Hey guys, I am using API Blueprint with aglio for our internal project, and since API Blueprint doesn't support file including currently, aglio implements one with the syntax {
"username": "alice",
"comments": [
{
"id": 1,
"content": "hello"
}
]
} and a {
"id": 1,
"content": "hello"
} the comment part in I consider it for some time and try making a syntax to support JSON file including, here is my effort, The syntax would be like, in previous case: {
"username": "alice",
"comments": [
{
"...": "include(commend_model.json)"
}
]
} using Its not a special case for API Blueprint, but something rather general, to try to think of JSON itself with the include capability, which I think may also be used in API Blueprint. Please take a look and give some suggestions, currently this json-include is working fine in some of my projects, any thoughts about it would be very appreciated, since I can't decide whether it is good and meaningful or not alone by myself :) |
Hey @reorx ! Thanks for sharing the idea. Recently we have launched (beta) of MSON – a syntax for describing data (not only) in API Blueprint. The idea is, you describe your data once and then ask for serialization into different formats. Using your examples it works like this: # Data Structures
## User
- username: alice
- comments (array[Comment])
## Comment
- id: 1
- content: hello and then you can ask to render it as JSON: # Resource [/r]
## Retrieve [GET]
+ Response (application/json)
+ Attributes (User)
What do you think? Will this help you? |
Is this feature anywhere in the pipeline? It would be very nice for us. |
I think that the fact you can't include external references for requests/response body examples and definition schema files is one of the very big downsides that Blueprint has in respect to other API definition languages. |
+1 |
@jonathancrosmer @lpbm @moon0326 check https://github.com/jamesramsay/hercule especially https://github.com/jamesramsay/hercule/blob/master/examples/api-blueprint/gist-fox.apib and would this work for you? |
@zdne I'm not following. Those two examples do not show much. What am I looking at? |
@zdne: yes, as long as it allows inclusion of any type of external resource, be it .md/.apib or xml, json that's good. Is it something Apiary will implement, or is your message an advise for us to use hercule before committing to apiary? |
Back ago I have prepared a list of solutions for splitting blueprint into multiple files (and using exteral assets): https://gist.github.com/zdne/137396a1c2d45f75b306 @jamesramsay put together the awesome Hercule tool which implements the syntax I would like to use for splitting blueprint into multiple parts. As for the external assets. Hercule works there as well albeit I am not sure if this should be the final syntax and suggested use inside JSON blobs especially through the prism of MSON. Nevertheless if you do not rely on editing inside Apiary you can use Hercule today to get most of this functionality.
We want to implement some transclusion based on the Does this clarify? |
Maybe you can circumvent that by using URLs? |
For fetching the documents perhaps yes but not for editing. |
Currently we have an Apiary blueprint stored in our git repository, which is connected to Apiary. The blueprint has many links to an internal server that hosts our JSON schema. |
@lpbm Hercule supports both local file (relative file paths) and remote file (URL) transclusion, and although labelled as a 'Markdown transclusion' should support any text file (.md, .apib, .json, .xml etc). One use case that might be similar to yours that some people are using Hercule for is transcluding JSON Schema generated by their application via HTTP, and also local file transclusion to increase the DRY-ness of their documentation. @jonathancrosmer spot on - we do something similar using Jenkins on our internal CI environment. At Adslot, whenever a commit is pushed to any branch, along with unit tests we compile the API Blueprint with Hercule, and then pass it into dredd. If all is passing, as part of the deploy task, we can optionally push to Apiary. We originally pushed directly to Apiary as soon as changes were made to the API docs, but we found this sometimes caused problems when we were working on larger releases with feature switches and such, thus we now deploy alongside the application. |
What about just allowing plain URIs to be specified? The renderer can decide whether to render the URI to a link or include its contents in the documentation output. This also saves us the trouble from having to deal with different Markdown flavors. |
That should be the case. |
Hi, Is there any news on this? Cheers, Tamas |
Hello everyone, I'm sorry for getting here late and reopening and digging old stuff. If this isn't the right place please forgive me. But, doing a research to develop blueprint mocks I've found this discussion and this is the closest that I've could find until now. I'm struggling to split my responses by model :(. Isn't it possible to referer a model into a different folder? |
Add the possibility to use Markdown links wherever an asset is expected (e.g. a payload body or schema).
The text was updated successfully, but these errors were encountered: