orval-labs/orval

Feature Request: Ability to exit on validation warnings

Closed this issue · 4 comments

Description

Right now we only exit when there are validation errors. We also want the ability to exit on warnings, since we don't want to introduce warnings into the codebase.

Warnings also generally point out good things we should fix anyway, e.g.

=> S2OError: (Patchable) path parameters must be required:true [limit in get:/api/v1/my_endpoint]

Hmm, for some reason process.exit(1)s are stripped in the @orval/core bundle (at least the one published to NPM, not a local build):

// node_modules/@orval/core/dist/index.js line 47758
var ibmOpenapiRuleset = require("@ibm-cloud/openapi-ruleset");
var { Spectral } = require_dist10();
var ibmOpenapiValidator = async (specs) => {
  const spectral = new Spectral();
  spectral.setRuleset(ibmOpenapiRuleset);
  const { errors, warnings } = await spectral.run(specs);
  if (warnings && warnings.length) {
    ibmOpenapiValidatorWarnings(warnings);
  }
  if (errors && errors.length) {
    ibmOpenapiValidatorErrors(errors);
  }
};

even though it's clearly in the code:

if (errors.length) {
ibmOpenapiValidatorErrors(errors);
process.exit(1);
}

There also doesn't appear to be any build steps that remove process calls. Anyone know what's up here?

I think it was reported here too about the Exit Code: #1497

Something funky is going on.

Hmm, for some reason process.exit(1)s are stripped in the @orval/core bundle (at least the one published to NPM, not a local build):

@ezequiel

I think it’s likely because the commit that added process.exit(1) was part of the latest 7.1.0 release. From the code you shared, it seems like you might be using a bundle of @orval/core from before that 7.1.0 release 👀

ok @ezequiel can you try 7.1.0 now that is is out?