Redocly / Redocly/redoc

[Bug] Object-level extensions missing when requestBody is an array of objects

Open
#2,723 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug
Dominant language
TypeScript
Stars
25.9k
Forks
2.4k
Avg merge
13h 10m
Merged PRs (30d)
4

Description

When the requestBody is an array of objects, the extension information specified at the object level is not displayed.

% cat openapi/openapi.yaml

openapi: 3.0.4
info:
  title: Article Posting API
  description: redoc issue sample. Attention to "x-cross-validation" extension !
  version: 1.0.0
servers:
  - url: http://localhost:8080
    description: development
paths:
  /article:
    post:
      summary: create one article
      requestBody:
        content:
          application/json:
            schema:
              title: ArticlePostRequest
              type: object
              properties:
                article:
                  $ref: '#/components/schemas/Article'
      responses:
        '200':
          description: 'OK'
          content:
            application/json:
              schema:
                title: ArticleResponse
                type: object
                properties:
                  article:
                    $ref: '#/components/schemas/Article'

  /articles/bulk:
    post:
      summary: create articles
      requestBody:
        content:
          application/json:
            schema:
              title: BulkArticles
              type: object
              properties:
                articles:
                  type: array
                  items:
                    $ref: '#/components/schemas/Article'
                  x-check-list-min:
                    value: 1
                  x-check-list-max:
                    value: 100
      responses:
        '200':
          description: 'OK'
          content:
            application/json:
              schema:
                title: BulkArticlesResponse
                type: object
                properties:
                  articles:
                    type: array
                    items:
                      $ref: '#/components/schemas/Article'

components:
  schemas:
    Article:
      title: Article
      type: object
      properties:
        title:
          type: string
        author:
          type: string
        sentence:
          type: string
        publishDate:
          type: string
          x-check-date-format:
            value: yyyyMMdd
        endDate:
          type: string
          x-check-date-format:
            value: yyyyMMdd
      x-cross-validation:
        - expression: publishDate < endDate
        - expression: publishDate = null
          condition:
            - endDate = null
        - expression: endDate = null
          condition:
            - publishDate = null

% npx @redocly/cli@2.1.4 build-docs \
  ./openapi/openapi.yaml \
  -o ./target/index.html \
  --theme.openapi.showExtensions=true

% open ./target/index.html 
Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with openapi/openapi.yaml and the Redocly CLI build-docs command shown in the report, then inspect the generated target/index.html. Trace how the requestBody array schema and its object-level extensions are rendered. Done means the x-check-list-min and x-check-list-max information is displayed for the array-of-objects request body.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.