Hi All, Question regarding usage of anyOf keyword ...
# pactflow
s
Hi All, Question regarding usage of anyOf keyword and de-referencing it in schema: We are using BDCT in Ruby and using rswag to generate the OAS...I've de-referenced the anyOf in the schema definition and do I need to de-reference it in the response as well ?
Copy code
responses:
  '200':
    description: User found
    content:
        application/vnd.api+json:
        schema:
          "$ref": "#/components/schemas/UserResponse"

schemas:
  UserResponse:
    type: object
    properties:
      data:
        "$ref": "#/components/schemas/User"
    included:
      type: array
      items:
      anyOf:
        - type: object
        properties:
          id:
            type: string
          type:
            type: string
        -type: object    
        properties:
          name:
            type: string
          type:
            type: string
    required:
      - data
UserResponse schema has anyOf and it is been de-referenced and User doesn't have the keyword
y
I would say yes, you would have to. There is also an issue with anyOf and the difficulties managing it. Your example is showing anyOf for the response being
[{"id":"foo","type":"bar"]
or
[{"name":"foo","type":"bar"]
If you have a client generating a pact file that only tests for one of those cases
[{"id":"foo","type":"bar"]
, they many never received the other anyOf object in this case as we wont have verified it`[{"name":"foo","type":"bar"]` in regular consumer driven testing for pact, you would use provider states and an actual verification of the provider to assert that when the provider was capable of providing both types of responses that consumer has required Have you seen any issues in verifying the contract, and how are you deferencing your OAS
s
Looking for some ruby libraries to dereference the OAS...Do you have any recommendations?
y
not in ruby no, I scripted up a javascript package to do it which can be used on the command line and executed with
npx
https://github.com/YOU54F/oas-merge
gratitude thank you 1