eduardoboucas / eduardoboucas/static-api-generator
static-api-generator generates .json
- Dominant language
- JavaScript
- Stars
- 148
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
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](https://css-tricks.com/creating-static-api-repository/).
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`:
```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
```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
```json
{
"results": [
{
"undefined_id": "10c8f19f2d98c3eb66ec911b5dc5abd0",
"author": "Hugo",
"title": "Lorem ipsum"
},
{
"undefined_id": "dfbdfa8f69d0b629153207a17e565fd9",
"author": "Hugo",
"slogan": "Lorem ipsum dolor"
}
],
"metadata": {
"itemsPerPage": 10,
"pages": 1
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with server.js and the source/:slogan blueprint shown in the issue, then inspect how the generator handles the source files and the slogans endpoint. Reproduce the generation into output and trace why both .json and slogans.json are written. Done means the configured endpoint produces the intended JSON structure without an unexpected filename.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100