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 raises invalid media examples (model composition)

See original GitHub issue

Describe the bug Making use of allOf raises no-invalid-media-type-examples

Expected behavior allOf combines the objects as expected

openapi: 3.1.0
info:
  version: '1.0'
  title: Test
  description: |
    Test OAS
  license:
    name: Copyright
    url: 'https://foo.com'
  contact:
    name: Contact
    url: 'https://www.foo.com'
    email: bar@foo.com
servers:
  - url: 'https://foo.com'
tags:
  - name: Test
    description: A Test API
paths:
  /test:
    get:
      summary: Retrieve a Test
      operationId: getTest
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestModel'
              example:
                address_1: boulevard Montmartre
                address_2: 5eme etage
                city: Paris
                country_state: null
                email: 'foo@bar.com'
components:
  schemas:
    TestModel:
      title: TestModel
      description: A Test Object
      allOf:
        - $ref: '#/components/schemas/BaseModel'
        - type: object
          properties:
            address_1:
              type: string
            address_2:
              type: string
            city:
              type: string
            country_state:
              type:
                - string
                - 'null'

    BaseModel:
      title: BaseModel
      type: object
      description: A Base test model for testing
      properties:
        email:
          type: string

When running the above, redocly complains about the example and all of the fields (excerpt from the validation)

Example value must conform to the schema: must NOT have additional properties `address_2`.

34 | email: foo@bar.com
35 | address_1: boulevard Montmartre
36 | address_2: 5eme etage
37 | city: Paris
38 | country_state: null

referenced from schemas/orders/test.yaml:29:15

Error was generated by the no-invalid-media-type-examples rule.

When removing the example from responses the linter stop complaining.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
petkostascommented, Sep 29, 2022

@SmoliyY Thanks! I can confirm this is now working as expected!

0reactions
SmoliyYcommented, Sep 26, 2022

Hi @petkostas! This issue fixed in 1.0.0.beta-110 version. Please, let us know if it works for you, thx)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lint: inaccurate examples warning produced when using ...
The lint rule no-invalid-media-type-examples is inaccurately reported as being violated when using a combination of schema inheritance and ...
Read more >
no-invalid-media-type-examples - Redocly
Disallow invalid media type examples by ensuring they comply with the corresponding schema definitions.
Read more >
AP English Literature and Composition Practice Exam (2012)
Section I of this exam contains 55 multiple-choice questions. Fill in only the circles for numbers 1 through 55 on your answer sheet....
Read more >
33 Problems With Media in One Chart - Visual Capitalist
Modern media is broken. In this infographic, we highlight 33 problems with the social and mass media ecosystem today.
Read more >
15 Photography Composition Techniques to Improve Your ...
In this guide we discuss 11 composition techniques in photography to ... There are many elements to consider, and all of them have...
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