So, for a demo I'm trying to put together I need t...
# pactflow
b
So, for a demo I'm trying to put together I need to publish an OpenAPI spec in JSON format as part of the BDCT flow. Here's a link to the spec: https://apigateway.spa.frisscloud.com/api/underwriting/swagger/v1/swagger.json When I publish, PactFlow tells me:
Copy code
Unable to parse "oas": Swagger schema validation failed. #/paths/~1api~1v1~1LogVariables/get/parameters/2 must have required property 'schema' #/paths/~1api~1v1~1LogVariables/get/parameters/2 must have required property 'content' #/paths/~1api~1v1~1LogVariables/get/parameters/2 must match exactly one schema in oneOf #/paths/~1api~1v1~1LogVariables/get/parameters/2 must have required property '$ref' #/paths/~1api~1v1~1LogVariables/get/parameters/2 must match exactly one schema in oneOf #/paths/~1api~1v1~1Request/post/parameters/0 must have required property 'schema' #/paths/~1api~1v1~1Request/post/parameters/0 must have required property 'content' #/paths/~1api~1v1~1Request/post/parameters/0 must match exactly one schema in oneOf #/paths/~1api~1v1~1Request/post/parameters/0 must have required property '$ref' #/paths/~1api~1v1~1Request/post/parameters/0 must match exactly one schema in oneOf #/paths/~1api~1v1~1underwriting~1Request/post/parameters/0 must have required property 'schema' #/paths/~1api~1v1~1underwriting~1Request/post/parameters/0 must have required property 'content' #/paths/~1api~1v1~1underwriting~1Request/post/parameters/0 must match exactly one schema in oneOf #/paths/~1api~1v1~1underwriting~1Request/post/parameters/0 must have required property '$ref' #/paths/~1api~1v1~1underwriting~1Request/post/parameters/0 must match exactly one schema in oneOf #/paths/~1api~1v1~1underwriting~1check~1{sessionId}/get/parameters/1 must have required property 'schema' #/paths/~1api~1v1~1underwriting~1check~1{sessionId}/get/parameters/1 must have required property 'content' #/paths/~1api~1v1~1underwriting~1check~1{sessionId}/get/parameters/1 must match exactly one schema in oneOf #/paths/~1api~1v1~1underwriting~1check~1{sessionId}/get/parameters/1 must have required property '$ref' #/paths/~1api~1v1~1underwriting~1check~1{sessionId}/get/parameters/1 must match exactly one schema in oneOf #/paths/~1api~1v1~1underwriting~1check/post/parameters/0 must have required property 'schema' #/paths/~1api~1v1~1underwriting~1check/post/parameters/0 must have required property 'content' #/paths/~1api~1v1~1underwriting~1check/post/parameters/0 must match exactly one schema in oneOf #/paths/~1api~1v1~1underwriting~1check/post/parameters/0 must have required property '$ref' #/paths/~1api~1v1~1underwriting~1check/post/parameters/0 must match exactly one schema in oneOf #/paths/~1api~1v1~1underwriting~1check/delete/parameters/0 must have required property 'schema' #/paths/~1api~1v1~1underwriting~1check/delete/parameters/0 must have required property 'content' #/paths/~1api~1v1~1underwriting~1check/delete/parameters/0 must match exactly one schema in oneOf #/paths/~1api~1v1~1underwriting~1check/delete/parameters/0 must have required property '$ref' #/paths/~1api~1v1~1underwriting~1check/delete/parameters/0 must match exactly one schema in oneOf #/paths/~1api~1v2~1underwriting~1sync/post/parameters/0 must have required property 'schema' #/paths/~1api~1v2~1underwriting~1sync/post/parameters/0 must have required property 'content' #/paths/~1api~1v2~1underwriting~1sync/post/parameters/0 must match exactly one schema in oneOf #/paths/~1api~1v2~1underwriting~1sync/post/parameters/0 must have required property '$ref' #/paths/~1api~1v2~1underwriting~1sync/post/parameters/0 must match exactly one schema in oneOf #/paths/~1api~1v2~1underwriting~1async/post/parameters/0 must have required property 'schema' #/paths/~1api~1v2~1underwriting~1async/post/parameters/0 must have required property 'content' #/paths/~1api~1v2~1underwriting~1async/post/parameters/0 must match exactly one schema in oneOf #/paths/~1api~1v2~1underwriting~1async/post/parameters/0 must have required property '$ref' #/paths/~1api~1v2~1underwriting~1async/post/parameters/0 must match exactly one schema in oneOf
I interpret this as 'the schema itself is invalid, and therefore I can't match it with a consumer contract'. Is that true and if so, what can I do to resolve it?
m
So when I get an OAS with an invalid schema or error, I put it into one of a few places to find out what’s wrong: 1. https://editor.swagger.io/ (easiest) 2. Redocly VS code plugin
The main problem is that the
tenant
parameter doesn’t have a data type / schema associated with it:
Structural error at paths./api/v1/Request.post.parameters.0
should have either a
schema
or
content
property
Bad:
Copy code
- name: tenant
  in: header
  description: Tenant id
  required: true
Good:
Copy code
- name: tenant
  in: header
  schema: 
    type: string
  description: Tenant id
  required: true
That’s most of the errors sorted, as it’s a repeated problem
There are two operations with the same name:
CreateRawRequestAsync
so one just needs renaming (I don’t think this breaks PactFlow but should be fixed anyway)
The last is that there is a request body on a
DELETE
. I don’t think this affects PactFlow either, but is a non-standard thing to do
Once I fixed the parameters, I got BDCT to progress to the next level.
b
Ah wonderful, thank you so much! This is excellent feedback. I'll create a modified version myself (unless you can send it to me if you still have it) and will show both variants to the folks in the demo.
👍 1