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

Schema is always overridden in the samples when using allOf in the preview #2575

Open
renke0 opened this issue Aug 26, 2024 · 3 comments
Open

Comments

@renke0
Copy link

renke0 commented Aug 26, 2024

Describe the bug

I am extending a component schema by using allOf. The first component definition (TestPage) contains a property with type, properties and the rest of the schema of the component. The second (Page) one only contains the same property with only a description, which I want to be the same for all extending objects. When using the preview command in the cli, the document I see in the browser has a response sample with said overridden property marked as null, regardless of its definition.

To Reproduce
Steps to reproduce the behavior:

  1. Given this redocly.yaml file
    None

  2. And this OpenAPI file(s)

openapi: 3.1.0
info:
  title: Test
  version: 1.0.0
paths:
  /test:
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestPage'
components:
  schemas:
    Page:
      type: object
      properties:
        page:
          type: integer
        total:
          type: integer
        content:
          description: Awesome description
    TestPage:
      allOf:
        - type: object
          properties:
            content:
              type: array
              items:
                $ref: '#/components/schemas/TestSummary'
        - $ref: '#/components/schemas/Page'
    TestSummary:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
  1. Run this command with these arguments... redocly ...
redocly preview-docs openapi.yaml
  1. See error
    The generated response sample for status 200 is this:
{
  "content": null,
  "page": 0,
  "total": 0
}

Expected behavior

I expected the property content declared in TestPage to contain its definition, regardless of being overridden in Page, since the second doesn't contain a schema.

{
  "content": [
    {
      "id": 0,
      "name": "This is a test"
    }
  ],
  "page": 0,
  "total": 0
}

Logs
-

OpenAPI description
-

Redocly Version(s)

1.19.0

Node.js Version(s)

v20.13.1

Additional context
-

@AlexVarchuk AlexVarchuk transferred this issue from Redocly/redocly-cli Aug 28, 2024
@AlexVarchuk
Copy link
Collaborator

Hi @renke0, thank you for the issue. We know this problem. For now, to get your expected behavior you can replace the order of your items inside AllOf.

@AlexVarchuk AlexVarchuk added the p2 label Aug 28, 2024
@moncefdhk999
Copy link

Hi @renke0, thank you for the issue. We know this problem. For now, to get your expected behavior you can replace the order of your items inside AllOf.

@moncefdhk999
Copy link

I recover my github which now many people use to destroy our global system

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

No branches or pull requests

4 participants
@AlexVarchuk @renke0 @moncefdhk999 and others