robertmassaioli/openapi-merge

Uncaught exception with common model

robertmassaioli opened this issue · 3 comments

Moved from: https://bitbucket.org/echo_rm/openapi-merge-cli/issues/16

I’m working with an API in which every object is defined in its own OAS definition file. The majority of them have this in the components section:

  responses:
    400error:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: ../../common/models/errorresponse.schema.yaml

If I set my openapi-merge.json file to only a single input file, it works fine. If I set it to two input files in which only one of them has the 400error defined, it works fine. However, if more than one input file as the 400error defined I get this error:

An uncaught exception was thrown Error: Could not resolve reference: ../../common/models/errorresponse.schema.yamlat isSchemaOrThrowError (C:\Users\steve.nay\node_modules\openapi-merge\dist\component-equivalence.js:27:15)at compare (C:\Users\steve.nay\node_modules\openapi-merge\dist\component-equivalence.js:66:29)at C:\Users\steve.nay\node_modules\openapi-merge\dist\component-equivalence.js:79:39at Array.every (<anonymous>)at compare (C:\Users\steve.nay\node_modules\openapi-merge\dist\component-equivalence.js:79:26)at C:\Users\steve.nay\node_modules\openapi-merge\dist\component-equivalence.js:79:39at Array.every (<anonymous>)at compare (C:\Users\steve.nay\node_modules\openapi-merge\dist\component-equivalence.js:79:26)at C:\Users\steve.nay\node_modules\openapi-merge\dist\component-equivalence.js:79:39at Array.every (<anonymous>)

So something about that 400error being defined in multiple files is throwing this error. I tried setting a different disputePrefix for each input file, but that didn’t make any difference.

What is really being asked for in this request, is for non-external references to be supported OR for pre-bundling to be supported such that all of the schemas are bundled together before then being merged together. Both would likely give you the behaviour that you are looking for.

I'm going to mark this issue as replaced by #10 and close this one.