express-openapi-validator icon indicating copy to clipboard operation
express-openapi-validator copied to clipboard

Unsupported $ref= at very end of yml file

Open kdthomflutter opened this issue 3 years ago • 0 comments

Getting an unsupported $ref issue on an 3.0.3 openAPI validation

Schemas are referenced from other files all over my spec but for some reason the last reference is causing this error

SubCompetition: required: - name - obfuscated type: object properties: name: type: string example: 'obfuscated ' description: 'The name of the obfuscated' obfuscated: type: string example: '123' description: 'The event id of the obfuscated' obfuscated2: type: array items: $ref: '../shared/obfuscated2.yaml#/components/schemas/obfuscated2'

` Unsupported $ref=.'../shared/obfuscated2.yaml#/components/schemas/obfuscated2'

  at Object.resolveReference (node_modules/express-openapi-validate/src/schema-utils.ts:32:13)
  at mapOasFieldsToJsonSchemaFields (node_modules/express-openapi-validate/src/schema-utils.ts:82:20)
  at Object.walkSchema (node_modules/express-openapi-validate/src/schema-utils.ts:51:16)
  at walk (node_modules/express-openapi-validate/src/schema-utils.ts:52:51)
  at node_modules/express-openapi-validate/src/schema-utils.ts:71:34
      at Array.forEach (<anonymous>)
  at Object.walkSchema (node_modules/express-openapi-validate/src/schema-utils.ts:66:6)
  at walk (node_modules/express-openapi-validate/src/schema-utils.ts:52:51)
  at node_modules/lodash/lodash.js:13469:38
  at node_modules/lodash/lodash.js:4967:15`

File definitely exists and is being referenced fine as far as I can tell, so not sure what's causing this issue. If I comment out the example property it works fine

kdthomflutter avatar Jan 24 '22 16:01 kdthomflutter