Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
## OpenAPI Forge - JavaScript

This repository is the JavaScript template for the [OpenAPI Forge](https://github.com/ColinEberhardt/openapi-forge), see that repository for usage instructions:
This repository is the JavaScript generator for the [OpenAPI Forge](https://github.com/ScottLogic/openapi-forge), see that repository for usage instructions:

https://github.com/ScottLogic/openapi-forge

## Development

### Running

To run this generator, you also need to have [OpenAPI Forge] installed, or the repository checked out. Assuming you have it installed as a global module, you can run this generator as follows:

```
$ openapi-forge forge
\ https://petstore3.swagger.io/api/v3/openapi.json
\ .
\ -o api
```

This generates an API from the Pet Store swagger definition, using the generator within the current folder (`.`), outputting the results to the `api` folder.

### Testing

The standard test script is used to execute the BDD-style tests against this generator.
Expand Down
18 changes: 18 additions & 0 deletions formatter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// there are issues with running prettier as a CLI command
// see: https://github.com/ScottLogic/openapi-forge/issues/133
// this is a workaround to run the prettier CLI as a node module
const cli = require("prettier/cli.js");

// map forge log levels to prettier log levels
const logLevels = [
/* quiet */
"silent",
/* standard */
"warn",
/* verbose */
"debug",
];

module.exports = (folder, logLevel) => {
cli.run(["--write", folder, "--loglevel", logLevels[logLevel]]);
};
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"test:generators": "\"./node_modules/.bin/cucumber-js\" -p generators",
"format:check:all": "prettier --check .",
"format:write:all": "prettier --write .",
"format:write": "prettier --write",
"lint:check:all": "eslint .",
"lint:write:all": "eslint --fix ."
},
Expand Down
2 changes: 1 addition & 1 deletion partials/modelIncludes.handlebars
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{#if models}}
{{#if models }}
const {
{{#each models}}{{@key}}, {{/each}}
} = require("./model");
Expand Down