apiaryio / mson

Markdown Syntax for Object Notation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

there is any MSON implementation in Ruby ?

solyarisoftware opened this issue · comments

Hi all
that in't a real issue, but just a question: there is any MSON implementation in Ruby language ?
I mean a MSON (Markdown) to JSON (and so in hash internal data structures) and viceversa ?

thanks
giorgio

Hey @Solyaris,

I had the same problem the other day, what we needed was the Data Structures branch of an api blueprint document:

API Blueprint map

You can see that the structure covers a full API use case with resource groups, single resources, actions on those resources including requests and responses. All we wanted, though, was the little red top level branch called Data structures.

You can check out this gem we made: minimum-term. It offers a rake task to convert MSON into (our flavour) of JSON Schema. You can use a minimal MSON document like this:

# Data Structures

# User
This will be my user model

## Properties
- id: (number, required)
...

Apart from that - I don't think you'll be lucky about the "viceversa" part, because doing JSON Schema to MSON wouldn't quite work as JSON Schema has many specifics that MSON doesn't (want to) have.

Edit: Removed the part where I said I implemented it using drafter because I just implemented this using RedSnow :)

commented

@jayniz Ingenious! Went through Minimum term and Zeta and I must give you a hat tip sir! I am pleasantly surprised somebody is thinking about these lines! Good stuff.

Regarding your findings – you are indeed correct, that MSON data structures are defined under API Blueprint Data Structure section(s). For the sake completeness – if you would define an Attributes section under a named Resource section you would also ended up with a globally defined MSON data structure. But this does not play any role in your use case.

Regarding the parser / renderer itself – we plan to support Drafter (CLI & C/C++ library) its node.js binding Protagonist and then a pure JavaScript port of Drafter alongside with REST API.

At this moment I do not see support for Red Snow as feasible (too many things to maintain 😕)

May I ask you whether you are using the version that spits API Blueprint AST or the one which is using Parse Result Refract?

Also you are on spot with

I don't think you'll be lucky about the "viceversa" part, because doing JSON Schema to MSON wouldn't quite work as JSON Schema has many specifics that MSON doesn't (want to) have

MSON is not on par feature-wise with JSON Schema and neither this is the plan (but we would still like to add some validation features)

@zdne oh you 😚

We just started making Zeta, so it's nowhere near production ready yet, but it scratches an itch we've been having for a long time. We'll see if other people also need something like this :)

May I ask you whether you are using the version that spits API Blueprint AST or the one which is using Parse Result Refract?

I first implemented the MSON->JSON Schema with drafter <1.0, then reimplemented for the other AST that drafter 1.0 spits out by default, and now that I switched back to RedSnow I think I'm back to the old AST, because RedSnow has drafter < 1.0 in its submodule, IIRC. Doesn't matter much, though, adjusting this is just a matter of a few minutes (now that I've done it a few times).