Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static-api-generator generates .json #1

Open
schmanat opened this issue Sep 28, 2017 · 3 comments
Open

static-api-generator generates .json #1

schmanat opened this issue Sep 28, 2017 · 3 comments

Comments

@schmanat
Copy link

schmanat commented Sep 28, 2017

First of all, thx for your greate tool. I'm playing arround with it and have a issue that i couldn't solve.

I read the article from CSS Tricks.

I create a source folder with the following structure:

source
    slogan1.yaml
    slogan2.yaml

the structure of slogan is only
author: "Hugo"
slogan: "Lorem ipsum ..."

I want to generate the following endpoint
/slogans

The Code of my server.js:

    const API = require('static-api-generator')
    const slogansAPI = new API({
        blueprint: 'source/:slogan',
        outputPath: 'output'
    })

    slogansAPI.generate({
        endpoints: ['slogans'],
    })

After generating it with npm start I get 2 json files

  • .json
  • slogans.json

Can you tell me what I'm doing wrong. The strange thing ist the content of slogans.json. It contains two result objects?

The content of .json seems right, but why is there no filename?

Content of slogans.json

    {
        "results": [
            {
                "results": [
                    {
                        "undefined_id": "10c8f19f2d98c3eb66ec911b5dc5abd0",
                        "author": "Hugo",
                        "title": "Lorem ipsum"
                    },
                    {
                        "undefined_id": "dfbdfa8f69d0b629153207a17e565fd9",
                        "author": "Hugo",
                        "slogan": "Lorem ipsum dolor"
                    }
                ]
            }
         ],
        "metadata": {
            "itemsPerPage": 10,
            "pages": 1
        }
    }

Content of .json

    {
        "results": [
            {
                "undefined_id": "10c8f19f2d98c3eb66ec911b5dc5abd0",
                "author": "Hugo",
                "title": "Lorem ipsum"
            },
            {
                "undefined_id": "dfbdfa8f69d0b629153207a17e565fd9",
                "author": "Hugo",
                "slogan": "Lorem ipsum dolor"
            }
        ],
            "metadata": {
            "itemsPerPage": 10,
            "pages": 1
        }
    }    
@david-genger
Copy link

I am having the same issue, can you please help me.

@ClydeDz
Copy link

ClydeDz commented Jun 4, 2019

I'm having the same issue. And if I add another level, the json output doesn't contain anything.

@gavinmcfarland
Copy link

I'm going to take a guess that static-api-generator always expects a collection and that collection has to be grouped by a folder.

As a temporary fix you could try using source/:slogans/:slogan and place all files in a sub folder source/slogans/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants