danielgtaylor / aglio

An API Blueprint renderer with theme support that outputs static HTML
4.75k stars 480 forks source link

Rendering "attributes" section and Data Structures #103

Open ghost opened 9 years ago

ghost commented 9 years ago

Aglio looks fantastic but I have problems rendering complex cases as such:

I have this file: https://raw.githubusercontent.com/samwiseapi/apiary-samwise/master/apiary.apib

where I got a) "attributes" sections such as

 + Response 200 (application/json)
      + Attributes (SampleDTO)

b) custom Data Structures such as (note the SampleProperties which is itself a custom Data Structure)

 # Data Structures

 ## SampleDTO (object)
 + SampleId: 123456789 (number,  required)  - Sample ID
 + SampleProperties: SamplePropertiesDTO
 + ClientSampleId: 1 (number, optional) - Identifier of Sample ID received from client in request
 + Events (array[SamplePropertiesDTO], required) - Collection of sample events 

when I run the file agains aglio, these parts are ignored apparently. Would it be possible to add rendering to aglio for these?

apiary.io renders Attribute section as a table and does not have Data Structures and nested data structures render working but there are plans http://stackoverflow.com/questions/29848375/apiblueprint-structures-to-achieve-desired-description/29901429#29901429 - check here. I though like aglio design more.

ryanquinlan commented 8 years ago

Does anyone have this working? I feel like I'm missing something as being able to describe what the request data looks like seems so fundamental to all of this I can't figure out how it's gone overlooked this long. Apiary does an OK job of rendering the attributes sections, but I'm not sure the cloud hosted model is going to work for my production needs.

Tried installing the beta referenced above, but that went all sorts of sideways and I'd expect those changes would have been merged into the master branch at this point anyway.

Appreciate any guidance here. This is what I'm trying to get to render out. I realize that the MSON doesn't support url encoded yet so I'll have to provide the body which is fine. Need the attributes to be displayed though. Hoping to see them look basically like the Parameters section used on the GETs

Thanks!

### Do something awesome [POST]
+ Attributes
    + message (string) - The message
    + author: boba@fett.com (string) - Author of the message

+ Request (application/json)
+ Request (application/x-www-form-urlencoded)
    + Body

            message=foo

+ Response 200
    + Headers

                Location: ID
benoittgt commented 8 years ago

Seems the related issue has been closed https://github.com/apiaryio/api-blueprint/issues/191. Any news on this one? Cheers

bloo commented 8 years ago

This has been an issue for me .. for the entirety of this issue being open. Is aglio being supported these days?

SvyatoslavVasiliev commented 8 years ago

I am really waiting this feature.

philsturgeon commented 8 years ago

Hey @danielgtaylor! Not to pointlessly bump you, but this is a big awesome feature that a lot of folks are looking forward to. Could you give us an update? πŸ˜„

danielgtaylor commented 8 years ago

@philsturgeon and everyone else on this thread, I am very sorry this is not implemented yet. Apiary has kept me extremely busy these last few months and I could not justify spending the time on Aglio. Today is my last day at Apiary. Once I have stable employment again, I hope to work on some new features for Aglio, but right now my focus needs to be elsewhere. I hope you can understand.

P.S. If anybody reading this is hiring either remote or in Seattle, please reach out: danielgtaylor@gmail.com

philsturgeon commented 8 years ago

Hey @danielgtaylor, thanks for getting back to me! Sorry to hear that, I just had a job swap that took a bit longer than I hoped and it can be a f**ker on the money. Pop on the http://slack.apisyouwonthate.com and we'll see if anyone in there is looking, or we can tweet something from the channel. It's got some eyes on it.

In the meantime, maybe you could add https://pledgie.com/ to this repo? I would certainly throw some money at you, and I'm sure some of the other 30ish participants in here would too. Maybe that would help get this feature up and running.

If not, I'll try and get you a PR, but I'm rammed myself. Isn't everyone. 😞

zhdanovartur commented 8 years ago

+1

dolfelt commented 8 years ago

πŸ‘

tucq88 commented 7 years ago

πŸ‘ Can't wait for this feature :)

jkryanchou commented 7 years ago

+1 I'm really looking forward to this feature. What time could the agilo support this.? @danielgtaylor

angmark0309 commented 7 years ago

@bniwredyc, I really like how you present the attributes as a table. Currently, I'm struggling to use your fork. Are there any tutorials to have this custom theme? So far, the steps I took were:

  1. install npm in my local project directory
  2. call npm init, which created the package.json
  3. add the devDependencies in the package.json
  4. run npm install

Results: created a node_module folder

Please let me know if I am missing any steps. Thank you

bniwredyc commented 7 years ago

@angmark0309 have you configured aglio in your Gruntfile?

angmark0309 commented 7 years ago

@bniwredyc So inside my node_module I only seeaglio-theme-kaitendirectory and inside that, the following files Changelog.md cache node_modules scripts styles README.md lib package.json src templates No Gruntfile. I think I'm installing the fork incorrectly since Im fairly new to this.

jkryanchou commented 7 years ago

@bniwredyc Your solution look so nice. and could you send a pull request to the repository in order to help us to use it?

bniwredyc commented 7 years ago

@angmark0309 I actually don't know how to use themes without grunt-aglio https://www.npmjs.com/package/grunt-aglio

bniwredyc commented 7 years ago

@ryanchou1991 done. Not that I think it will be merged (there are some other changes), but still.

jkryanchou commented 7 years ago

@bniwredyc Awesome job. I would try your solution later. I'm so appreciated for that you could offer that solution. Before I saw your comment. I have used markdown table sheet to instead of the attributes. While it couldn't be compatible with blueprint syntax very well.

marks commented 7 years ago

@bniwredyc - you dont have a triple.jade version by any chance, do you?

antongorodezkiy commented 7 years ago

For me I've ended up with attributes in description for now

<?php
    /**
     * Add product
     *
     * **Body Attributes:**
     *
     * | name | type |
     * | --- | --- |
     * | some | some |
     * 
     * @Post("/")
     * @Versions({"v1"})
     * @Transaction({
     *      @Request({
     *          "name": "Some project",
     *          "domain": "some.github.com"
     *      }),
     *      @Response(200, body={}),
     *      @Response(422, body={})
     * })
     */
OrangeDog commented 7 years ago

@angmark0309

npm install kaiten-hq/aglio-theme-kaiten -g
aglio --theme-template /usr/local/lib/node_modules/aglio-theme-kaiten/templates/index.jade
jkryanchou commented 7 years ago

πŸ‘

philsturgeon commented 7 years ago

I made a little progress! One of the folks on slack.apisyouwonthate.com gave me a snippet, which I've expanded to make attributes show in our own custom theme.

In mixins.jade I replaced the JSON Schema output and added this new mixin:

         if request.schema
                - var schema = JSON.parse(request.schema)
                  h5.attributes-title Attributes
                  +AttributeTable(schema)

mixin AttributeTable(schema)

    table.attributes-list(style="width: 100%;")
        thead.attributes-header
            each props, name in schema.properties || []
                tr
                    td
                        strong= self.urldec(name)
                    td.attribute-type
                        != props.type ? (props.enum ? 'enum' : props.type) : 'string'
                    td
                        if schema.required && schema.required.indexOf(name) >= 0
                            span.required-field (required)
                        else
                            span.optional-field (optional)

                    td
                        ul
                            if props.default
                                li.text-info.default
                                    strong Default:&nbsp;
                                    span= props.default

                            if props.example
                                li.text-muted.example
                                    strong Example:&nbsp;
                                    span= props.example

                            if props.enum
                                li.choices
                                    strong Choices:&nbsp;
                                    ul
                                        each value in props.enum
                                            li
                                                code= self.urldec(value)
                                                = ' '

                if props.description
                    tr
                        td
                        td(colspan=3)
                            em
                                != self.markdown(props.description)

                if props.items
                    tr
                        td(colspan=4)
                            div.nested-attributes
                                +AttributeTable(props.items)

                if props.properties
                    tr
                        td(colspan=4)
                            div.nested-attributes
                                +AttributeTable(props)

It works with nested attributes, and with a little CSS on it, it looks... ok well it looks terrible but its good enough to get this task off my desk for now.

screen shot 2017-05-11 at 2 00 37 pm

Obviously im no designer.

Can somebody do something with this? Nicen it up and make a PR to aglio themes?

11mb commented 7 years ago

@philsturgeon thx for your code snippet! Im trying it to use for arrays, like in:

###User
+ id: 123 (number)
+ `communication_methods` (array[CommunicationMethods])

The snippet won't work because props.items or props.properties is empty in the AttributeTable mixin.

Your script solves the problem in the template by adding recursiveness, but the data isn't coming from aglio (in case of arrays). Did you solve this?

philsturgeon commented 7 years ago

I did not! Honestly I use Open API and ReDoc these days, it's solved this sort of problem for me.

-- Phil Sturgeon Sent from my iPhone and there's probably typos because I'm probably cycling

On Aug 21, 2017, at 13:40, 11mb notifications@github.com wrote:

@philsturgeon thx for your code snippet! Im trying it to use for arrays, like in:

User

  • id: 123 (number)
  • communication_methods (array[CommunicationMethods])` The snippet won't work because props.items or props.properties is empty in the AttributeTable mixin.

Your script solves the problem in the template by adding recursiveness, but the data isn't coming from aglio (in case of arrays). Did you solve this?

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

philsturgeon commented 6 years ago

It looks like https://github.com/danielgtaylor/aglio/pull/337 solves this issue perfectly, but Travis is failing and there's no commit activity. Hopefully somebody picks it up.

Grummfy commented 6 years ago

it could really be helpful