question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`allOf` in oas3 is handled incorrectly under Windows making examples not fail the mediatype validation

See original GitHub issue

Describe the bug

allOf in oas3 is handled incorrectly making examples fail the validation

To Reproduce Steps to reproduce the behavior:

  1. Given this .redocly.yaml file
lint:
  extends:
    - recommended
  rules:
    info-contact: off
  1. And this OpenAPI file: (openapi.yaml)
openapi: "3.0.3"
info:
  title: bugtest
  version: "1.0"
  description: Demo
  license:
    name: DEMO
    url: https://demo.com
servers:
  - url: http://demo.com/api

components:
  examples:
    DemoResponse:
      description: Demo
      value:
        name: "demo"
        demo: "Demo"

  schemas:
    Demo:
      type: object
      required:
        - name
        - demo
      properties:
        name:
          type: string
          maxLength: 100
        demo:
          type: string

    DemoAllOf:
      allOf:
      - type: object
        required:
          - name
        properties:
          name:
            type: string
            maxLength: 100
      - type: object
        required:
          - demo
        properties:
          demo:
            type: string

paths:
  /demo:
    summary: "Demo with schema NO allOf and NO baseRef"
    get:
      summary: "Get demo no refs"
      operationId: getDemoNoRefs
      description: "Returns Demo No Refs"
      responses:
        200:
          description: Demo No Refs
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Demo"
              examples:
                Demo1:
                  $ref: "#/components/examples/DemoResponse"

  /demoAllOf:
    summary: " Demo with schema allOf and NO baseRef"
    get:
      summary: "Get demo no refs"
      operationId: getDemoAllOf
      description: "Returns Demo refs with baseRef"
      responses:
        200:
          description: Demo refs with baseRef
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DemoAllOf"
              examples:
                Demo:
                  $ref: "#/components/examples/DemoResponse"
  1. Run this command: npx @redocly/openapi-cli lint openapi.yaml
  2. See error On Windows 10: NONE On github ubuntu-latest: warnings from rule: no-invalid-media-type-examples because allOf is not correctly handled

Expected behavior No warnings should be generated on ubuntu-latest or WSL 2 with Ubuntu 20.04 (other linux versions not tested)

Logs If applicable, add logs to help explain your problem.

OpenAPI definition If applicable, add an OpenAPI definition and .redocly.yaml configuration file that helps reproduce the problem. At a minimum, please state the specification version(s) you’re using (e.g. 2.0, 3.0, 3.1).

openapi-cli Version(s) What version of openapi-cli are you using? latest (with npx)

Node.js Version(s) What version of node.js are you using? Latest LTS Version: 14.15.1 (includes npm 6.14.8)

Additional context Add any other context about the problem here.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RomanHotsiycommented, Nov 28, 2020

@CommCody in this rule, we decided to disallow additional properties by default (like if each schema had additionalProperties: false). This is a very common mistake people make (do not set additionalProperties: false).

You can configure this behaviour in the .redocly.yaml:

lint:
  rules:
    no-invalid-media-type-examples:
      severity: warn
      disallowAdditionalProperties: false

See: https://redoc.ly/docs/cli/built-in-rules/#no-invalid-media-type-examples

It is strange it does not show any warnings in Windows. We have to check this.

0reactions
antonyccommented, Dec 23, 2022

Confirm, reproduces for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

`allOf` in oas3 is handled incorrectly under Windows making ...
allOf in oas3 is handled incorrectly under Windows making examples not fail the mediatype validation #230.
Read more >
oneOf, anyOf, allOf, not - Swagger
You can use it to validate the request body contains all the necessary information about the object to be updated, depending on the...
Read more >
OpenAPI Specification v3.0.3 | Introduction, Definitions, & More
The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.
Read more >
Redocly CLI changelog
Fixed incorrect behavior for the no-invalid-media-type-examples ... Ability to create config (e.g. redocly.yaml ) from string or object.
Read more >
OASValidation policy | Apigee X - Google Cloud
The OASValidation (OpenAPI Specification Validation) policy enables you to ... standard location within the API proxy bundle: apiproxy/resources/oas .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found