swagger-api / swagger-api/swagger-ui

TypeError: Cannot read properties of undefined (reading 'match')

Open
#8,273 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Error loading content from the uploaded file. Detail is that the content of the file is read in the frontend, below the source code and screenshot of the error

Q&A (please complete the following information)
  • OS: Linux
  • Browser: Firefox
  • Version: 106.0.5
  • Method of installation: npm
  • Swagger-UI version: 4.14.2
  • Swagger/OpenAPI version: OpenAPI 3.0
Screenshots

errorswagger

Content & configuration

Source code example:

import { useState } from "react";
import SwaggerUI from "swagger-ui-react";
import "swagger-ui-react/swagger-ui.css";
function App() {
  const [file, setFile] = useState();
  const handleChange = (e) => {
    const fileReader = new FileReader();
    fileReader.readAsText(e.target.files[0], "UTF-8");
    fileReader.onload = (e) => {
      setFile(e.target.result);
    };
  };
  return (
    <div>
      <h2>Error Swagger Console</h2>
      <input type="file" onChange={handleChange} />
      {file && <SwaggerUI spec={file} />}
    </div>
  );
}
export default App;

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

Start with the provided React App example and reproduce the failure by selecting an uploaded file in Firefox. Trace how the FileReader result is passed through the SwaggerUI spec prop, then define completion as loading the uploaded OpenAPI 3.0 content without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.