apiaryio / mson

Markdown Syntax for Object Notation
MIT License
900 stars 180 forks source link

Any parsers for mson? #27

Open tylerlong opened 9 years ago

tylerlong commented 9 years ago

Any parsers for mson?

zdne commented 9 years ago

Hey @tylerlong – at the moment MSON parser is part of the API Blueprint parser – Drafter the simplest MSON document in API Blueprint would look like:

# Data Structures
## My Object 
- name: john

(e.g. you need to start with # Data Structures to before defining your MSON types)

rcrooks commented 9 years ago

@zdne we do a lot data-driven documentation around our APIs in addition to the apiary reference, and I could see some real uses for a MSON2JSON parser...just sayin...:)

zdne commented 9 years ago

@rcrooks we do have an OSS tool that does it but it is not wrapped in a CLI interface together with MSON parser just yet...

zdne commented 9 years ago

TODO: Update this thread once C++ Drafter with refract + MSON rendering is ready.

jayniz commented 9 years ago

I'm interested as well

zdne commented 9 years ago

Hey @rcrooks, @jayniz and @tylerlong – I just want to give you a head up – the API Blueprint parser that can parse MSON (and produces JSON) out of it is now available:

Or you can play with the protagonist directly in Atom – https://twitter.com/zdne/status/647325114393079808

jayniz commented 9 years ago

Thanks for the heads up Z - I was already using drafter to get the AST as json, but I was looking to transform it into json schema.

zdne commented 9 years ago

@jayniz it is now offering transformation to JSON, JSON schema coming soon™

hobofan commented 8 years ago

@zdne any way to convert into JSON as the examples in https://github.com/apiaryio/mson/blob/master/README.md do it?

MSON

- id: 1
- name: A green door
- price: 12.50
- tags: home, green

JSON

{
    "id": "1",
    "name": "A green door",
    "price": "12.50",
    "tags": [ "home", "green" ]
}
zdne commented 8 years ago

@hobofan at this moment it would be a little bit "hacky"

Minimal blueprint would be something like:

# Data Structures
## My Object
- id: 1
- name: A green door
- price: 12.50
- tags: home, green

but you have to add something to render it as application JSON eg.

# GET /a
- response 200 (application/json)
    - attributes (My Object)

And then run it through blueprint parser (drafter / protagonist)

So you will end up with:

screen shot 2015-10-12 at 12 25 58 pm

zdne commented 8 years ago

@hobofan all the main pieces are there but there is no dedicated tool to make turn an MSON document into (multiple?) JSONs – I guess not enough demand at this time. Besides how it would work if the MSON document would have many data structures in it? Would it spit multiple JSONs?

jayniz commented 8 years ago

@hobofan https://github.com/hobofan all the main pieces are there but there is no dedicated tool to make turn an MSON document into (multiple?) JSONs – I guess not enough demand at this time. Besides how it would work if the MSON document would have many data structures in it? Would it spit multiple JSONs?

We currently put each data structure from MSON into the definitions of the schema, and then set the properties of the schema itself to something like {properties: { "myType": { "$ref": "#/definitions/myType"}} so when you would check an object foo against myType in that schema, you'd need to wrap it like this {"myType": foo}.

As for the MSON to json schema - until a proper tool is released we're using drafter to parse the minimal MSON you mentioned into a refract ast and then manually transform this onto a json schema as described above.

jayniz commented 8 years ago

What I meant to say is: @zdne yes yes, there is demand for MSON->Json schema :)

jayniz commented 8 years ago

We open sourced the gem we made to convert MSON to JSON Schema. See this comment in issue #41

zdne commented 8 years ago

For what it's worth: I was playing today with Tonic and put together a simple (and ugly!) notebook to get JSON and JSON Schema from an MSON document: https://tonicdev.com/zdne/mson-renderer

Next step: Add an endpoint to it