ApiBlueprints parameter that yield result like Stripe's errors "attributes"? - apiblueprint

I'm new to Stripe and I'd like generate a result that looks like the "Attributes" part of the Errors part : https://stripe.com/docs/api/curl#errors
It's looks like a table with two column, even though it's not a table.
I don't know how I can make this.
For information, I'm using Aglio to generate the template.

Cyril,
There is no easy way to do this in Markdown that I know of. You have two options:
Create your own layout template that manually adds this information, then tell aglio to use it.
Include some basic HTML in your API Blueprint. Here is an example. It just creates a definition list which describes the error attributes using the same CSS that already exists on the page to describe URI parameters.
You can use Markdown to create the tables of response types and codes, and if you want to use a three-column layout you can use the middle and right CSS classes.
Hope this helps!

Related

Gatsby & GraphQL: Transforming a String field into markdown

I have a GraphQL schema on a headless CMS. I'm using gatsby-source-graphql on a Gatsby site to get data from it.
There is a content field MyType_BlogPost.body of type String. This contains markdown code.
Is it possible to transform (with gatsby-transformer-remark) that into MarkdownRemark (or similar) so that it will automatically get subfields like html that contain the data one would expect (html code transformed from the markdown source)? I suspect subfields would be the way to do this, but I'm not 100 % of that.
I also suspect this could help but I'm not sure: https://www.gatsbyjs.org/docs/schema-customization/
Thank you.
If the field contains markdown code which you would like to transform into html, you should be able to do that using remark.
Remark is the library that gatsby-transformer-remark uses under the hood.
https://remark.js.org/
Specifically, look at the API section in their docs.

MVC #Html.ValidationSummary Default Text

Is it possible to set any global defaults for use with the #Html.ValidationSummary?
We're using it throughout our solution and want it always to show the same text. For example, we can achieve the text as follows:
#Html.ValidationSummary(False, "Validation Errors Occured")
However, we want to avoid the developer needing to specify the text. Instead, we'd like them to simply code as follows:
#Html.ValidationSummary()
Not providing you exact answer you are looking but you can create new extension method as per your need for validation summary. and use that method across the site for validation summary. You will have more control on your create code.
Have a look at this post how James created new method for it.

Is it possible to specify parameters which go into the post body with blueprint?

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.

Joomla component "attachments" allow html in input

this question might be a bit special. I am using this Joomla 2.5 extensions to give authors the abilty to add Attachments to articles: Joomla Attachments
The extension renders an input field called "description" in a backend form to insert an file description for the provided file. Unfortunately it´s not taking HTML tags which I need. By saving the form it seems a strip_tags() or preg_replace() or something similar cleans the input. I combed through the code of the attachments extension but couldn´t find a place where the input is cleaned or saved.
To hopefully stay in the Question + Answer rule of Stackoverflow:
Is there a class which extensions inherit from the Joomla Core to save form data to a DB-table ( which also could be responsible to clean and validate user input )?
thanks for any idea,
tony
You should see how the field is defined first:
1. Form definition
look into the
administrator/component/yourcomponent/models/forms/somename.xml
there you could find a form definition, if so it will also specify the field type: depending on the type there are several available filters; for example the default textarea will strip html, and you need to set
filter="raw"
in order to enable it. see http://docs.joomla.org/Standard_form_field_and_parameter_types for a list of fields, click and you can find the available format options.
2. model
If the model inherits from JModelAdmin or JModelForm or other JModel* it will automatically handle binding of the forms' data to the database, look for the Save function which should receive the form $data.
3. more
There are at least another dozen possibilities. If the above didn't help, try finding the form: possibly you could find it just by looking at the markup. Once you have the form, check the following fields:
option
task
view
This should help you find the php code that is invoked based on the form:
if view is set, maybe in ./views/someview/view.html.php you could find the saving logic.
if task is set, look for a function with the same name in ./controller.php
if task contains a ".", look for the controller in the ./controllers/ folder.
if option is not the name of your component, your component is sending the data to another component for saving, and most likely set a return-url

How to use helper inside model function in CakePHP

Now before you burn me at the stake hear me out!
I want some keywords of a product description field to link to other products (kinda like mediawiki links), however at some point I need to make these associations and link the keywords up, so I'll need to do a search on each curly-braced word I find in the description and produce a formatted version of the description to cut down on processing these keyword links every time the description is displayed.
For ease/consistency I am creating all product links with a custom helper, and all I need to do is pass the product row in and the helper products a link for me with any options I specify. The only this is, is that I need to now do this in beforeSave() so I can populate description_formatted.
At the minute, beforeSave() checks for the original description row, then calls a private method in the model which matches each keyword, queries the db for a matching row... that is as far as I've got.
Just like any other MVC, Cake makes big restrictions how to couple your classes. This is needed to keep script kiddies to shoot themselves in the foot. However, there is a niche workaround for cake if you really need to get along: http://book.cakephp.org/view/933/The-App-Class
How I would do this? With the helper I would replace all curly braces words into links and when the user hovers the linked word I would call an Ajax which will get the word description or the link or whatever you need to do. This way you request the description only when it's needed.
If you still insist to use the helper - it's just a class in PHP, so you can include it in your Model, create an object of the class and use it's functions.
The third option is to create your own class and use it both in Model and the Helper.

Resources