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

failed to create example from schema object: TypeError: e.map is not a function #1059

Open
dfstio opened this issue Dec 28, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dfstio
Copy link

dfstio commented Dec 28, 2024

Describe the bug

When running docusaurus gen-api-docs all, the several warnings are generated:

WARNING: failed to create example from schema object: TypeError: e.map is not a function

and later, when running the site using docusaurus start, the error occur

e.map is not a function
TypeError: e.map is not a function
    at eval (webpack-internal:///./node_modules/allof-merge/dist/index.cjs:6:6746)
    at Array.map (<anonymous>)
    at U (webpack-internal:///./node_modules/allof-merge/dist/index.cjs:6:6736)
    at H (webpack-internal:///./node_modules/allof-merge/dist/index.cjs:6:6225)
    at eval (webpack-internal:///./node_modules/allof-merge/dist/index.cjs:6:13373)
    at a (webpack-internal:///./node_modules/allof-merge/dist/index.cjs:6:2118)
    at eval (webpack-internal:///./node_modules/allof-merge/dist/index.cjs:6:14680)
    at e.merge (webpack-internal:///./node_modules/allof-merge/dist/index.cjs:6:14706)
    at mergeAllOf (webpack-internal:///./node_modules/docusaurus-theme-openapi-docs/lib/theme/Schema/index.js:10:114)
    at SchemaNode (webpack-internal:///./node_modules/docusaurus-theme-openapi-docs/lib/theme/Schema/index.js:38:38)

Expected behavior

Should generate without warnings and run docs site without errors

Current behavior

Generate errors as described above

Possible solution

To fix the code in
https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/main/packages/docusaurus-plugin-openapi-docs/src/openapi/createRequestExample.ts
https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/main/packages/docusaurus-plugin-openapi-docs/src/openapi/createResponseExample.ts
where catch error occur

Steps to reproduce

Run docusaurus gen-api-docs all with

openapi: 3.1.0
info:
  title: MinaTokens API
  description: API for interacting with Mina Fungible Tokens and NFTs.
  version: "0.12.5"
servers:
  - url: https://minatokens.com/api/v1/
    description: Mina Devnet
paths:
  /token/mint:
    post:
      summary: Mint new tokens to a specified address.
      operationId: mintTokens
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TokenMintTransactionParams"
      responses:
        "200":
          description: Successfully built mint transaction.
          content:
            application/json:
              schema:
                type: object
components:
  schemas:
    TokenTransactionType:
      type: string
      enum:
        - "token:mint"
        - "token:transfer"
    TokenTransactionBaseParams:
      type: object
      properties:
        txType:
          type: string
          enum:
            $ref: "#/components/schemas/TokenTransactionType"
          description: Type of the token transaction.
    TokenMintTransactionParams:
      allOf:
        - $ref: "#/components/schemas/TokenTransactionBaseParams"
        - type: object
          properties:
            txType:
              type: string
              enum:
                - "token:mint"
              description: Must be "token:mint"

The repo where it can be reproduced is at https://github.com/zkcloudworker/zkcloudworker-docs/tree/open-api

Context

I want to add OpenAPI to docs site

Your Environment

"@docusaurus/core": "^3.6.3",
"@docusaurus/preset-classic": "^3.6.3",
"docusaurus-plugin-openapi-docs": "^4.3.1",
"docusaurus-theme-openapi-docs": "^4.3.1",
"typescript": "~5.7.2",
node v23.3.0

@dfstio dfstio added the bug Something isn't working label Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant