Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any parsers for mson? #27

Open
tylerlong opened this issue May 31, 2015 · 15 comments
Open

Any parsers for mson? #27

tylerlong opened this issue May 31, 2015 · 15 comments

Comments

@tylerlong
Copy link

Any parsers for mson?

@zdne
Copy link
Contributor

zdne commented Jun 1, 2015

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
Copy link

rcrooks commented Jun 1, 2015

@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
Copy link
Contributor

zdne commented Jun 2, 2015

@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
Copy link
Contributor

zdne commented Aug 18, 2015

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

@jayniz
Copy link

jayniz commented Sep 25, 2015

I'm interested as well

@zdne
Copy link
Contributor

zdne commented Sep 26, 2015

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
Copy link

jayniz commented Sep 26, 2015 via email

@zdne
Copy link
Contributor

zdne commented Sep 26, 2015

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

@hobofan
Copy link

hobofan commented Oct 10, 2015

@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
Copy link
Contributor

zdne commented Oct 12, 2015

@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
Copy link
Contributor

zdne commented Oct 12, 2015

@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
Copy link

jayniz commented Oct 12, 2015

@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
Copy link

jayniz commented Oct 12, 2015

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

@jayniz
Copy link

jayniz commented Oct 21, 2015

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

@zdne
Copy link
Contributor

zdne commented Jan 28, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants