Skip to content

Support for enum mapping #797

Open
Open
@smeng9

Description

@smeng9

Describe the bug

Current gen-api-docs command does not support generating docs with enum mapping
The doc will fail to build eventually

Expected behavior

The docs should build successfully

Current behavior

With following schema

{
  "openapi": "3.1.0",
  "info": {
    "title": "Service API Document",
    "version": "0.1"
  },
  "tags": [],
  "paths": {
    "/deliver": {
      "post": {
        "summary": "deliver <POST>",
        "operationId": "deliver",
        "description": "",
        "tags": [],
        "parameters": [],
        "responses": {},
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeliverBody"
              }
            }
          }
        }
      }
    },
    "/read-sensors": {
      "get": {
        "summary": "read_sensors <GET>",
        "operationId": "readSensors",
        "description": "",
        "tags": [],
        "parameters": [],
        "responses": {}
      }
    }
  },
  "components": {
    "schemas": {
      "DeliverBody": {
        "additionalProperties": false,
        "properties": {
          "side": {
            "$ref": "#/components/schemas/ExecutionCommand"
          }
        },
        "required": [
          "side"
        ],
        "title": "DeliverBody",
        "type": "object"
      },
      "ExecutionCommand": {
        "oneOf": [
          {
            "const": 0,
            "title": "NO_COMMAND"
          },
          {
            "const": 1,
            "title": "DELIVER_LEFT"
          },
          {
            "const": 2,
            "title": "DELIVER_RIGHT"
          }
        ],
        "title": "ExecutionCommand",
        "type": "integer"
      }
    }
  }
}

It will build with an empty <SchemaTab>

         <div>
          <span
            className={"badge badge--info"}
          >
            oneOf
          </span><SchemaTabs>
            
          </SchemaTabs>
        </div>

Then the docs will fail to build

Possible solution

Support enum mapping.

Steps to reproduce

  1. Replace the petstore.yaml file in the example https://github.com/PaloAltoNetworks/docusaurus-template-openapi-docs/blob/main/examples/petstore.yaml project
  2. Run gen-api-docs and then build
  3. Build will fail with Error: Docusaurus static site generation failed for 1 paths:
  4. Check the output deliver.api.mdx file

Screenshots

Context

We need to build docs with enum support

Your Environment

  • Version used: 3.0.0-beta.10
  • Environment name and version (e.g. Chrome 59, node.js 5.4, python 3.7.3): [INFO] Docusaurus version: 3.2.1, Node version: v20.10.0
  • Operating System and version (desktop or mobile): macOS Sonoma 14.2
  • Link to your project:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requestedreviewing 👀Undergoing manual audit to determine if issue should still be activev3.0.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions