krakenjs / hapi-openapi

Build design-driven apis with OpenAPI (formerly swagger) 2.0 and hapi.
Other
211 stars 75 forks source link

stripVendorExtensions recursion #145

Open JProgrammer opened 6 years ago

JProgrammer commented 6 years ago

Hi with the new stripVendorExtensions on api docs the code does not take into account recursive structures which will result in an error

    at RegExp.[Symbol.match] (<anonymous>)
    at String.match (native)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:50:16)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:51:22)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:51:22)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:51:22)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:51:22)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:51:22)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:51:22)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:51:22)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:51:22)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:51:22)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:51:22)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:51:22)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:51:22)
    at stripVendorExtensions (/Users/admj012/projects/bablProducts/node_modules/hapi-openapi/lib/index.js:51:22)

Here is a minimal openapi spec to replicate the issue

swagger: '2.0'
info:
  title: Recursion
  version: 1.0.0
paths:
  /recursion:
    get:
      responses:
        '200':
          description: 200 OK
          schema:
            $ref: '#/definitions/Recursion'
definitions:
  Recursion:
    type: object
    properties:
      healthStatus:
        $ref: '#/definitions/Recursion'
tags: []
tlivings commented 6 years ago

Hmm, that function should not be following references at all. Will double check.