-
Notifications
You must be signed in to change notification settings - Fork 2
Replace the custom parameter and representation DSL with MSON #42
Comments
Been thinking about this for a few days, and I wonder if it'd be better to go (with the exception of capabilities), full MSON. We can't support entering in all of your parameters and representation data with one annotation because we still need to support decorators for individual items, but something like this might work:
And if you need to support enums, you could do this:
That would allow us to start documenting enums properly, without adding something like an |
I like it, it also gives us the ability to use alternatives down the line with custom parsers. Maybe clearly label it as MSON in the annotation so people can add JSON schema or OpenAPI? |
Updated the original sec to have better support for enum documenting. |
https://github.com/apiaryio/mson
Basically, we're running into issues adding new things (like examples) into the Mill DSL for
@api-param
and representation annotations (see #41). Instead of trying to reinvent the wheel ourselves, we should just move over to MSON and be done with it.Advantages of MSON over our existing description DSL:
Disadvantages:
Solving this would be three parts:
@api-param
syntax with MSON@api-field
,@api-type
,@api-label
, and@api-options
in representations with a single new@api-data
annotation, that also uses MSON for describing the piece of data.MSON flavor
Since we require capabilities, and writing enum/options/members on the same line as the parameter, we'll need to have our own MSON flavor:
This should allow us to retain the core parts of MSON portability, while also retaining some flexibility for Mill-specific features like capabilities, and single line definitions.
Unfortunately, this means we'll need to build our own parser, but at least the spec part of this is easy to understand, and will be easy to implement.
@api-param
Swapping out the
@api-param
DSL for MSON would be relatively easy (pending an MSON parser) as all of that logic is contained withinParamAnnotation::parse
. Instead of manually parsing the docblock with regex, we'd feed it into the MSON parser and get back our data, and then send that along to the overall Mill parsing engine.For example:
Will become:
@api-data
Doing the same will also be simple, since everything is contained within the
FieldAnnotation:parser
method.Will become:
This'll allow us to cut back on the annotation complexity of representation data by killing
@api-label
,@api-field
,@api-type
, and@api-options
.The text was updated successfully, but these errors were encountered: