pactflow / swagger-mock-validator

Other
14 stars 5 forks source link

Vendor specific content types are not providing correct cross comparison #12

Closed YOU54F closed 1 year ago

YOU54F commented 2 years ago

Pre-condition

Vendor specific extension

headers: { “Content-Type”: “application/vnd.api+json” }

Repro https://github.com/pactflow/swagger-mock-validator/tree/vnd_issue/issues/vnd

  1. False Positive - If content-types are the same (other than application/json), detection is not taking place.
    • OAS has vendor specific extension = TRUE
    • Consumer has vendor specific extension = TRUE
      npx @pactflow/swagger-mock-validator https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/repro/oas_vnd.yaml https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/pacts/pactflow-example-consumer-vnd-pactflow-example-provider.json
  2. Valid Failure ( Content Type & Extra Field )
    • OAS has vendor specific extension = FALSE
    • Consumer has vendor specific extension = TRUE
      npx @pactflow/swagger-mock-validator https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/repro/oas.yaml https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/pacts/pactflow-example-consumer-vnd-pactflow-example-provider.json
  3. Valid Failure ( Extra Field )
    • OAS has vendor specific extension = FALSE
    • Consumer has vendor specific extension = FALSE
      npx @pactflow/swagger-mock-validator https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/repro/oas.yaml https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/pacts/pactflow-example-consumer-pactflow-example-provider.json
  4. Valid Failure ( Content Type Mismatch )
    • OAS has vendor specific extension = TRUE
    • Consumer has vendor specific extension = FALSE
      npx @pactflow/swagger-mock-validator https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/repro/oas_vnd.yaml https://raw.githubusercontent.com/pactflow/swagger-mock-validator/vnd_issue/issues/vnd/pacts/pactflow-example-consumer-pactflow-example-provider.json

Expected behaviour.

All above cases should fail validation. If consumer and provider specify vendor specification application/json types (and other content-types), they should support the same validation as per regular mime times

mefellows commented 2 years ago

Great work - thanks Yousaf! I'll add to our backlog for review and prioritisation.

mefellows commented 1 year ago

This should now be addressed by #26 and #25 .

Goltergaul commented 1 year ago

@mefellows awesome, do you know when this makes it into a next release?

YOU54F commented 1 year ago

25 went out two weeks ago, #26 went out this morning as 12.1.0

I noted the GH release tags aren't updated, so raised #27

mefellows commented 1 year ago

Just in case you meant "released to PactFlow", this will happen in the next few days, likely tomorrow.

mefellows commented 1 year ago

I've just tested the above on the latest version (12.1.0) and they all fail validation - which is expected. I think we can close this now?

YOU54F commented 1 year ago

Sounds good Matt and yeah good shout on "released to PactFlow"

We will report back here when this lands in PactFlow, but for now the thread will be closed. If anyone reading has any new issues, please feel free to fill out a new issue :)