request.path-or-method.unknown error if url contains `:text` at the end

Issue #93 invalid
Alex C created an issue

Swagger.yaml

...
  /hello/{token}:world:
    post:
...

custom.json

      "request": {
        "method": "POST",
        "path": "/hello/token:world",
        "matchingRules": {
          "$.path": {
            "match": "regex",
            "regex": "\\/hello\\/(.*?)\\:world"
          },
...

When running swagger-mock-validator openapi.yaml custom.json

1 error(s)
        request.path-or-method.unknown: 1
...
   mockDetails: {
       ....
        value: '/hello/token:world'
      },
...
     specDetails: {
        location: '[root].paths',
        pathMethod: null,
        pathName: null,
        specFile: 'openapi.yaml',
        value: {
          '/hello/{token}:world': [Object]
        }

Looks like spec was parsed correctly but it’s not able to match the request

Comments (4)

  1. Sebastian Tello Account Deactivated

    Hi Alex, your swagger file seems invalid. The char : in YAML may have an special meaning depending where it is:

    Instead of

    /hello/{token}:world:
    

    use quotes for the path:

    "/hello/{token}:world":
    

    Otherwise the first : is interpreted as the end of the key name in the map. You can paste your spec in https://editor.swagger.io/ to check it is valid.

    If the problem persists please attach the spec (or a simplified version of it) to this ticket

  2. Alex C Account Deactivated reporter

    I tried with both ' and “ around the path in the openapi.yaml Still the same error, so I don’t think that’s the reason it’s failing

  3. Sebastian Tello Account Deactivated

    Alex, can you share files of your swagger and pact to reproduce the problem?

  4. Log in to comment