PhillippOhlandt/pmtoapib

Using collection folders breaks output

Frug opened this issue · 8 comments

Frug commented

Rendering a collection that uses folders to organize requests produces output missing most fields.

I believe this is because postman's folders are parent "item" objects that don't contain methods/requests/responses.

Eg:

{
     "variables": [],
     "info": {
         "name": "/sample",
         "_postman_id": "b4c4bb85-f353-b7b7-eb5a-f47dbe5d7f27",
         "description": "",
         "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
     },
     "item": [
         {
             "name": "categories folder",
             "description": "",
             "item": [
                 {
                     "name": "/categories",
                     "request": {
                         "url": "{{host}}/categories",
                         "method": "GET",
                         "header": [],
                         "body": {},
                         "description": ""
                     },
                     "response": []
...

produces

## sample []

 ### sample []

 DESCRIPTION

 + Request

     + Headers



 + Response 200 (application/json)

     + Headers

             NAME: VALUE

     + Body

             <!-- include(responses-200-.json) -->

Hey,

thanks for the report. We don't use folders inside Postman so I ignored them for now. I will look at it and implement that ASAP.

One more thing. How would you like them to be handled? The same as they were all collection root items?

Frug commented

Thanks for the response!

We use a the API Blueprint spec for groups (aglio handles this nicely by making menu items for the groups).

https://apiblueprint.org/documentation/specification.html#def-resourcegroup-section

# Group Blog Posts

## Resource 1 [/resource1]

 ...

# Group Authors
Resources in this groups are related to **ACME Blog** authors.

## Resource 2 [/resource2]

 ...

Ah yeah, we use that too. In our use case, each collection is a group which will be included in an index.apib, so not sure how to handle it here. Will think about it.

Ok, I think it's best when I generate the apib like now when there are no folders in the collection (to fit my use case at work) and generate an apib like your example above with a group for each folder when the collection contains folders. Can we nest folders in Postman even deeper? That could be a problem too.

Frug commented

Nope, fortunately (for us) there is only one level of folder nesting.

Generating an index.apib with a group for each folder would be great. You could use an include for each group so the index.apib is just the group headers and includes.

# Group A
<!-- include(a/index.apib) -->

# Group B
<!-- include(b/index.apib) -->

Sounds like a plan. Might take a while though because I am not sure when I have time to do that. It requires some rewriting of the current app code.

Frug commented

Terrible news! Postman now supports nesting folders.

I'd be fine with only supporting a max of 1 level. It's not clear to me how you'd handle more depth.