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

Add warning / error when something else than YAML is passed #4

Open
noraj opened this issue May 11, 2018 · 4 comments
Open

Add warning / error when something else than YAML is passed #4

noraj opened this issue May 11, 2018 · 4 comments

Comments

@noraj
Copy link

noraj commented May 11, 2018

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
Copy link
Author

noraj commented May 11, 2018

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 noraj changed the title Generated API is malformed Generated API is malformed / EOL detectiion fails May 28, 2018
@noraj noraj changed the title Generated API is malformed / EOL detectiion fails Generated API is malformed / EOL detection fails May 28, 2018
@noraj
Copy link
Author

noraj commented May 28, 2018

A question comes to me, does static-api-generator only take YAML in input or JSON too?

IOHelpers.prototype.parseFile = function (contents, extension) {
switch (extension) {
case '.yml':
case '.yaml':
return Promise.resolve(yaml.safeLoad(contents))
}

I think this is only for YAML so we can transform this issue to a feature request : support JSON as input.

@noraj
Copy link
Author

noraj commented Jun 7, 2018

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 noraj changed the title Generated API is malformed / EOL detection fails Add warning / error when something else than YAML is passed Jun 7, 2018
@noraj
Copy link
Author

noraj commented Jun 10, 2018

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

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

1 participant