Redocly / Redocly/redoc

Partial request sample with nested discriminator

Open
#314 7 comments 4 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 discriminator isn't at the top level, the request sample doesn't show all fields.

Example:
In the default pet store, in the POST /pet, we see that huntingSkill is present, a specific field from petType=Cat

{
  "id": 0,
  "category": {
    "id": 0,
    "name": "string",
    "sub": {
      "prop1": "string"
    }
  },
  "name": "Guru",
  "photoUrls": [
    "string"
  ],
  "tags": [
    {
      "id": 0,
      "name": "string"
    }
  ],
  "status": "available",
  "petType": "Cat",
  "huntingSkill": "lazy"
}

Nesting the petType from line 107 like this, for example:

-$ref: '#/definitions/Pet'
+type: object
+properties:
+ foo:
+  $ref: '#/definitions/Pet'

We don't get the huntingSkill in the request sample:

{
  "foo": {
    "id": 0,
    "category": {
      "id": 0,
      "name": "string",
      "sub": {
        "prop1": "string"
      }
    },
    "name": "Guru",
    "photoUrls": [
      "string"
    ],
    "tags": [
      {
        "id": 0,
        "name": "string"
      }
    ],
    "status": "available",
    "petType": "string"
  }
}

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 request sample with the default pet store and the nested schema change shown around demo/swagger.yaml line 107. Inspect the request-sample generation entry point to determine why the nested discriminator loses the Cat-specific field; done means the nested example includes huntingSkill while preserving the surrounding fields.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.