Skip to content

Referenced schemas lose default property #2588

Open
@onavratil-monetplus

Description

@onavratil-monetplus

Describe the bug

Redocly often fails to display default values of properties, although they are defined in accordance with standard.

To Reproduce
Steps to reproduce the behavior:

Given this api and separate model:

openapi: 3.1.0
tags:
  - name: test
info:
  title: Bundle Sample
  version: '0.1.0'
  description: |
    Sample API
  contact:
    name: Ondřej Navrátil
    email: [email protected]
servers:
  - url: '127.0.0.1'
    description: localhost
paths:
  /test-endpoint:
    post:
      summary: Sample endpoint
      operationId: post-something
      description: |-
        xxx.
      requestBody:
        content:
          application/json:
            schema:
                type: object
                properties:
                  testProperty:
                    $ref: some-model.yaml
                  testProperty2:
                    title: Test Property 2
                    description: |
                      Whatever2.
                    type: string
                    enum:
                      - ABCD
                      - EFGH
                    default: ABCD
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  testProperty:
                    $ref: some-model.yaml
      tags:
        - test

Model:

title: Test Property
description: |
  Whatever.
type: string
enum:
  - ABCD
  - EFGH
default: ABCD

Running the following

$ redocly build-docs sample-api.yaml 

...redocly fails to display defaults in the referenced schemas. Note that the same model is displayed correctly when explicitly dereferenced.

image

Expected behavior

Defaults are displayed even in referenced models.

Logs

No idea what the warning means, but AFAIK is not related to the problem.

(node:2452) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Found undefined and using theme.openapi options
Prerendering docs

🎉 bundled successfully in: redoc-static.html (43 KiB) [⏱ 2ms].

OpenAPI description

See above

Redocly Version(s)

$ redocly --version
1.25.0

Node.js Version(s)

$ node --version
v22.8.0

OS, environment

$ uname -a
Linux nb-onavratil2 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Additional context

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions