Giter Club home page Giter Club logo

openapi_optimise's Introduction

openapi_optimise

Build Tested on APIs.guru Tested on Mermade OpenAPIs Greenkeeper badge

Logo

A set of utility functions to optimise OpenApi (swagger) 2.0 specifications

These optimisations may be most useful when the OpenApi specification has been converted from another format or automatically generated, and may improve code-generation. Differencing the input and output may also identify errors in your specification not detected by most parsers/validators. Disk/over-the-wire savings of 25% even after gzip compression are easily possible.

Default optimisations

  • Converting repeated parameters into common parameters
  • Removing duplicated common parameters
  • Removing unused common parameters
  • Promotion of repeated mandatory action-level parameters to path-level
  • Removal of redundant parameter default properties
  • Removal of incorrect parameter type, property and format combinations
  • Removal of redundant enums (from boolean types)
  • Removing empty parameter descriptions
  • Removing redundant consumes/produces
  • Compression of different representations of functionally equivalent empty schemas
  • Removing unused and empty tags
  • Removing empty definitions
  • Removing empty responses
  • Removing unused securityDefinitions
  • Using tabs for indenting the output if serialised as JSON by the included utility
  • Using a compact yaml format if serialised as YAML by the included utility
  • Using UTF8 encoding for the output if serialised by the included utility

Not enabled by default are

  • Optional expansion of all local non-circular $ref's prior to
  • Automatic creation of $ref's for repeated model elements

As these currently consume excessive memory or have not been sufficiently tested

Usage

var opt = require('openapi_optimise');

var options = {};
// options.verbose = 1;
var dest = opt.defaultOptimisations(swagger,options);

Included command-line tool

  • openapi_optimise applies all safe optimisations by default
openapi_optimise [options] {infile} [{outfile}]

Options:
  -h, --help           Show help                                       [boolean]
  -v, --verbose        verbosity level, repeat for more logging          [count]
  -n, --nondefault     apply non-default operations                    [boolean]
  -u, --unindent       no indentation/linefeeds                        [boolean]
  -a, --analyse        analyse structure of specification              [boolean]
  -e, --expand         expand all local $refs before any model compression
                                                                       [boolean]
  -i, --inline         inline $refs rather than moving to #/definitions[boolean]
  -j, --jsyaml         use jsyaml for output, default jgexml           [boolean]
  -s, --skip-defaults  do not perform default optimisations            [boolean]
  -t, --preserve-tags  preserve tags with vendor extensions            [boolean]
  -y, --yaml           read and write specification in yaml format (default
                       JSON)                                           [boolean]
  -r, --yamlread       read specification in yaml format               [boolean]
  -w, --yamlwrite      write specification in yaml format              [boolean]

Tests

To run a test-suite:

node testRunner {path-to-APIs}

The test harness currently expects files named swagger.yaml or swagger.json and has been tested against

openapi_optimise's People

Contributors

augustobmoura avatar greenkeeper[bot] avatar mikeralphson avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

openapi_optimise's Issues

An in-range update of reftools is breaking the build 🚨

The dependency reftools was updated from 1.0.6 to 1.0.7.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

reftools is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 11 commits.

  • 229b079 Publish
  • 4bf072b reserve console.log for API output, refs #147
  • e585eba tests: add http2 server tests, refs #148
  • 402e60c build: update dependencies, refs #148
  • 513fe4b Publish
  • afa96a8 feat: add prevalidate option to validate externally $ref'd files before including
  • 14b0b0e fix: s2o, Error.message is not enumerable, refs #145
  • 3edd748 fix: only tidy parameters we're not going to delete, refs #145
  • dc6ef15 Added testcase for #145 (#146)
  • 1beefad docs: fix a stray ` character in s2o README
  • bdcc91d docs: update CHANGELOG (still mostly manually)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of reftools is breaking the build 🚨

The dependency reftools was updated from 1.0.3 to 1.0.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

reftools is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 46 commits.

There are 46 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of js-yaml is breaking the build 🚨

The dependency js-yaml was updated from 3.12.0 to 3.12.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

js-yaml is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 5 commits.

  • b6d2609 3.12.1 released
  • 7b68122 Browser files rebuild
  • 784d1d0 Add "noArrayIndent" option (#461)
  • 00bba11 Fix description of onWarning (#460)
  • 2d1fbed Travis-CI: increase tests timeout

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of reftools is breaking the build 🚨

The dependency reftools was updated from 1.0.2 to 1.0.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

reftools is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 62 commits.

  • 4862e15 Publish
  • cbb91c1 misc; comments/.gitignore
  • 6bfe799 deps; update node-fetch
  • 6fc257b deps; more removal of eslint from packages
  • c53b48f deps; update
  • 88c3f9b travis; skip openapi3-examples for now
  • 5b3808a resolver; omit sorting of ref paths, see octokit
  • 8c33b93 resolve utility; set options.fatal true
  • 1483dcb misc; update .gitignore
  • a36947a .gitignore; utils/
  • 8828fb3 jptr; allow + and %20 for spaces in $refs
  • 842b115 travis; skip APIs.guru and OpenAPI-Definitions for now
  • 335f433 oas-validate; allow openapi half of failing tests to actually pass...
  • 9a42f63 travis; add eslint as a devdep
  • 172666d travis; Node 6 doesn't support npx

There are 62 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of reftools is breaking the build 🚨

The dependency reftools was updated from 1.0.4 to 1.0.5.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

reftools is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 49 commits.

  • 92ab5dd Publish
  • 49de9ae Merge branch 'v5prep'
  • d11d126 docs; update spec link in s2o README
  • e67a82e Attempt to attach requestBody after parameters if still present, refs #141
  • bcfef04 Remove duplication vetween oas-resolver.js/resolve.js
  • f816fc6 Merge pull request #140 from pderaaij/v5prep
  • 2f69f87 reftools/jptr; handle non-encoding + correctly, refs #137
  • a76c3ce validator; Add missing dependency call-me-maybe (#139)
  • f7bce96 enable validation in ajv
  • f7d8d2b docs; add missing column for input filters description
  • 9143a40 boast; fix unhandled promise rejection error
  • 0d4a67e Call linter for each content object (#136)
  • 1923166 Adds propogation of response key to the linter (#134)
  • c7da7b0 docs; update converter README with CLI options
  • 299f62a converter; add refSiblings option to CLI, refs #130

There are 49 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.