static-api-generator icon indicating copy to clipboard operation
static-api-generator copied to clipboard

Add warning / error when something else than YAML is passed

Open noraj opened this issue 7 years ago • 4 comments

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.

noraj avatar May 11 '18 19:05 noraj

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.

noraj avatar May 11 '18 20:05 noraj

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.

noraj avatar May 28 '18 22:05 noraj

As static-api-generator support only YAML it should raise an error or a warning when something else than .yml or .yaml are provided.

noraj avatar Jun 07 '18 11:06 noraj

And of course I'll have a feature request to support JSON input too.

noraj avatar Jun 10 '18 14:06 noraj