Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
boutique
Advanced tools
Readme
Looking for the best fashion for your MSON AST? Boutique offers the finest quality, luxury representations to emphasize natural beauty of your AST.
Imagine you have some MSON to describe body attributes in your API Blueprint. Drafter should be able not only to parse it, but also to provide representations of those body attributes in formats you specified, e.g. in application/json
. Boutique is a simple tool to do exactly that.
Boutique takes an MSON AST and provides a representation of it in JSON, JSON Schema or other formats.
NOTE: Boutique knows nothing about hypermedia. For example, it understands that
application/hal+json
means it should generate JSON, but it generates plain JSON. To generate HAL document properly, the AST has to explicitly contain all HAL structures already on input to this tool.
Using the MSON AST from this example as the ast
variable, we can convert it by Boutique to a representation:
boutique = require 'boutique'
boutique.represent
ast: ast,
contentType: 'application/json'
, (err, body) ->
# body contains following string:
# '{"id":"1","name":"A green door","price":12.50,"tags":["home","green"],"vector":["1","2","3"]}'
boutique.represent
ast: ast,
contentType: 'application/schema+json'
, (err, body) ->
# body contains following string:
# '{"type":"object","properties":"id":{"type":"string"},"name":{"type":"string"},"price":{"type":"number"},"tags":{"type":"array"},"vector":{"type":"array"}}'
NOTE: Refer to the MSON Specification for the explanation of terms used throughout this documentation.
Generate representation for given content type from given MSON AST.
boutique.represent({ast, contentType}, cb)
ast
(object) - MSON AST in form of tree of plain JavaScript objects.
contentType
: application/schema+json
(string, default)
Smart matching takes place. For example, if following formats are implemented and provided by Boutique...
application/json
application/xml
application/schema+json
...then matching will work like this:
image/svg+xml; charset=utf-8
→ application/xml
application/schema+json
→ application/schema+json
application/hal+json
→ application/json
NOTE: Distinguishing JSON Schema draft versions by matching according to
profile
parameter is not implemented yet.
cb
(Represent Callback, required) - callback function
callback(err, repr, contentType)
err
: null
(object, default) - Exception object in case of errorrepr
(string) - final string representation of given AST in given formatcontentType
(string) - selected content type, which was actually used for rendering the representationInside the Boutique repository you can execute the following to run the test suite:
$ npm install
$ npm test
Fork & Pull Request.
Boutique is released under the BSD license. See LICENSE.
FAQs
The finest representations to emphasize natural beauty of your MSON AST
The npm package boutique receives a total of 25 weekly downloads. As such, boutique popularity was classified as not popular.
We found that boutique demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.