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

validateOuput() produces false positives when OAS schema uses internal $ref #2364

Closed
mtjandra opened this issue Aug 18, 2023 · 1 comment
Closed

Comments

@mtjandra
Copy link
Contributor

mtjandra commented Aug 18, 2023

Context

validateOutput() is not producing expected error when response doesn't match OAS schema that includes an internal $ref

openapi: 3.0.0
info:
  description: service description
  version: '0.1'
  title: service title
tags:
- name: tag1
  description: tag1 description
paths:
  "/test":
    get:
      tags:
      - tag1
      summary: ''
      description: ''
      operationId: testCreateOne
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/TestCreateOneResponse"
components:
  schemas:
    TestCreateOneResponse:
      type: object
      description: ''
      properties:
        output:
          "$ref": "#/components/schemas/OutputType"
      required:
      - output
    OutputType:
      type: string
      description: ''

Current Behavior

Error not produced when response does not match OAS schema that includes an internal $ref. See #2363 for more details.

{
  "_tag":"Right",
  "right":{
    "statusCode":200,
    "headers":{
      "x-powered-by":"Express",
      "content-type":"application/json; charset=utf-8",
      "content-length":"2",
      "etag":"W/\"2-vyGp6PvFo4RvsFtPoIWeCReyIC8\""
    },
    "body":{
      
    }
  }
}

Expected Behavior

Error should be produced when response does not match OAS schema that includes an internal $ref. See #2363 for more details.

{
  "_tag":"Left",
  "left":[
    {
      "path":[
        "body"
      ],
      "code":"required",
      "message":"Request body must have required property 'output'",
      "severity":0
    }
  ]
}

Possible Workaround/Solution

See #2363

Steps to Reproduce

See test case

Using example schema

{
  "schema":{
    "type":"object",
    "properties":{
      "output":{
        "$ref":"#/__bundled__/OutputType"
      }
    },
    "required":[
      "output"
    ]
  }
}

With empty body

{ "body": {} }

validateOutput() did not produce any errors. Expected error about required property output

Environment

  • Version used:
  • Environment name and version (e.g. Chrome 39, node.js 5.4):
  • Operating System and version (desktop or mobile):
  • Link to your environment/workspace/project:
@chohmann
Copy link
Contributor

This was released in version 5.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants