Closed robbinjanssen closed 3 years ago
This should be possible. Seems like problem is with the _
in the type name. Renaming Project1_Get
to X
seemed to work.
Note _
is reserved character per MSON spec – see https://github.com/apiaryio/mson/blob/master/MSON%20Specification.md#6-reserved-characters--keywords
However I believe we are having a bug here in our implementation cc @pksunkara
You are correct, drafter now approves the markdown using the following example:
FORMAT: 1A
HOST: https://test.api.com/
# Test API
Hi, welcome to the API!
# Group Projects
Wow, we are using projects!
### Retrieve single project [GET /projects/{id}]
+ Parameters
+ id: `5` (string, required)
+ Response 200 (application/json)
+ Attributes (object)
+ data (Project1Get, required)
# Data Structures
## ProjectLink (object)
+ self: `https://test.api.com/projects/5` (string, required)
## ProjectIdentifier (object)
+ type: `projects` (string, required)
+ id: `5` (string, required)
## Project1Get (ProjectIdentifier)
+ attributes (object, required)
+ number: `PRO-5` (string) - A readable identifier for employees to refer to projects.
+ links (ProjectLink, required)
But indeed I think it's a bug, both aglio and the apiaryio interface are rendering it wrong:
Edit: whoops, I see apiaryio is rendering it correct! But it places the type/id at the bottom in this case. My preference would be placing it at the top.
I'll wait before refactoring my docs again ;-)
@robbinjanssen If you want them to be at the top, please do something like this:
## Project1Get
+ Include ProjectIdentifier
+ attributes (object, required)
+ number: `PRO-5` (string) - A readable identifier for employees to refer to projects.
+ links (ProjectLink, required)
@pksunkara cool thanks!
A simple example of the bug is as follows:
# GET /projects
+ Response 200 (application/json)
+ Attributes (object)
+ data (B_B, required)
# Data Structures
## A_A
+ a: a
## B_B (A_A)
+ b: b
@zdne I think this is related to https://github.com/apiaryio/snowcrash/issues/335. What do you say?
Hi, I've got a question/proposal about data structures. Maybe this is more MSON related but I'll start here. To keep data structures nice and tidy, i'd like as little duplicate data as possible, therefor it would be nice if data structures could extend each other.
Assume the following data structure:
In the
links
attribute ofProject1_Get
I re-use theProject_Link
object which works great. But suppose I need the following DataStructure as well:Now there is duplicate data in my data structures because the
Project1_Identifier
contains thetype
andid
attribute, but also theProject1_Get
contains it. It would be great if I could do the following:In the following example drafter returns errors: