openapi-to-postman icon indicating copy to clipboard operation
openapi-to-postman copied to clipboard

Error Error: Expected a regexp or string in /properties/entries/items/0/properties/product

Open khazamov opened this issue 3 years ago • 1 comments

Hi,

I'm trying to convert JSON schema to postman collection using openapi-to-postman. I get

at Object.convertRequestToItem (/opt/homebrew/lib/node_modules/openapi-to-postmanv2/lib/schemaUtils.js:2437:9)
Error faking a schema. Not faking this schema. Schema: {
required: [ 'entries' ],
type: 'object',
description: 'Defines a batch of operations.',
properties: {
  entries: {
    type: 'array',
    description: 'The request entries to be processed in the batch.',
    maxItems: 2,
    minItems: 2,
    items: [Object]
  }
}
} Error Error: Expected a regexp or string in /properties/entries/items/0/properties/product
  at run (/opt/homebrew/lib/node_modules/openapi-to-postmanv2/assets/json-schema-faker.js:24791:21)
  at jsf (/opt/homebrew/lib/node_modules/openapi-to-postmanv2/assets/json-schema-faker.js:24834:14)
  at safeSchemaFaker (/opt/homebrew/lib/node_modules/openapi-to-postmanv2/lib/schemaUtils.js:188:19)
  at Object.convertToPmBodyData (/opt/homebrew/lib/node_modules/openapi-to-postmanv2/lib/schemaUtils.js:1429:20)
  at Object.convertToPmBody (/opt/homebrew/lib/node_modules/openapi-to-postmanv2/lib/schemaUtils.js:1904:25)
  at /opt/homebrew/lib/node_modules/openapi-to-postmanv2/lib/schemaUtils.js:2483:37
  at /opt/homebrew/lib/node_modules/openapi-to-postmanv2/node_modules/lodash/lodash.js:4967:15
  at baseForOwn (/opt/homebrew/lib/node_modules/openapi-to-postmanv2/node_modules/lodash/lodash.js:3032:24)
  at Function.forOwn (/opt/homebrew/lib/node_modules/openapi-to-postmanv2/node_modules/lodash/lodash.js:13082:24)
  at Object.convertRequestToItem (/opt/homebrew/lib/node_modules/openapi-to-postmanv2/lib/schemaUtils.js:2437:9)

The schema part where it throws an error looks like this:

      "ProductsCustomBatchRequest": {
        "required": [
          "entries"
        ],
        "type": "object",
        "properties": {
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductsCustomBatchRequestEntry"
            },
            "description": "The request entries to be processed in the batch."
          }
        },
        "description": "Defines a batch of operations."
      },

I'm aware that it's JSON schema faker that is not accepting the format, but it's extremely unclear. I've checked open issues on JSON schema faker project and couldn't find anything that would explain this. Do you have any pointers for me please?

khazamov avatar Dec 31 '21 10:12 khazamov

@khazamov Could you possibly share your specification or modified and shrunk version that can produce the same error? Looking at the schema you mentioned by you, it contains another reference (#/components/schemas/ProductsCustomBatchRequestEntry) which can cause this error.

I wasn't able to find any issue with the current data you shared so asking for it in detail.

VShingala avatar Feb 02 '22 12:02 VShingala

@khazamov I am closing this issue as we were not able to reproduce this issue. Please feel free to open it again if you are still facing this issue 🙇‍♂

akshaydeo avatar Feb 07 '23 09:02 akshaydeo