static-api-generator
static-api-generator copied to clipboard
Add warning / error when something else than YAML is passed
I wanted to try the generator API so I installed it: npm i static-api-generator
I created a generator for my JSON data:
const API = require('static-api-generator');
const api = new API({
addIdToFiles: true,
blueprint: 'data/:page/:category',
outputPath: 'temp/api/',
pluralise: false
});
api.generate({
endpoints: ['page', 'category']
});
then run it: node script.js.
And the result is that I have one char per entry:

And if I put addIdToFiles to false I have the whole content as one string

So it's like newline terminator are not properly detected.
I'm running it under archlinux with LN (\n) as final newline and utf-8 as charset. And I'm using node v10.0.0. All data files are JSON.
I tried with https://github.com/benhughes/static-api and it works well so this come from static-api-generator and not from my side.
A question comes to me, does static-api-generator only take YAML in input or JSON too?
https://github.com/eduardoboucas/static-api-generator/blob/81979fae5252ef5eb2ed2714262c567a9589ba67/lib/io.js#L17-L22
I think this is only for YAML so we can transform this issue to a feature request : support JSON as input.
As static-api-generator support only YAML it should raise an error or a warning when something else than .yml or .yaml are provided.
And of course I'll have a feature request to support JSON input too.