Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toSatisfyApiSpec doesn't recognize : in path that is not a parameter #286

Open
aradbar opened this issue Nov 9, 2022 · 0 comments
Open
Labels
bug Something isn't working

Comments

@aradbar
Copy link

aradbar commented Nov 9, 2022

Are you using jest or chai?
jest

Are you using OpenAPI 2, 3.0.X, or 3.1.0?
3.0.3

Describe the bug clearly
When having a path that contains a hard-coded : in it (that does not signify a parameter) toSatisfyApiSpec still treats it as a parameter and ignores the text after the :. that causes a mixup between different paths.

Steps to reproduce the bug:

  1. Have a spec with two paths that are identical except for an ending that container a :. for example
    POST /api/{prefix}/example:one
    POST /api/{prefix}/example:two
  2. Test a response to one of them with toSatisfyApiSpec
  3. See error

    expected received to satisfy the '200' response defined for endpoint 'POST /api/{prefix}/example:two' in your API spec

    received did not satisfy it because: response must have required property 'two'

    received contained: { body: { one: 'foo' } }

    The '200' response defined for endpoint 'POST /api/{prefix}/example:two' in API spec: {
      '200': {
        description: 'Two',
        content: {
          'application/json': {
            schema: {
              type: 'object',
              required: [ 'two' ],
              properties: { two: { type: 'string' } }
            }
          }
        }
      }
    }

See full example in my branch - https://github.com/aradbar/OpenAPIValidators/blob/bug-report-1/packages/jest-openapi/__test__/colonInUrlBug.test.ts

What did you expect to happen instead?
toSatisfyApiSpec to be able to differentiate between the two paths

Are you going to resolve the issue?

@aradbar aradbar added the bug Something isn't working label Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant