diff --git a/backend/src/services/spec/index.ts b/backend/src/services/spec/index.ts index a25b4057..d5cbb7a8 100644 --- a/backend/src/services/spec/index.ts +++ b/backend/src/services/spec/index.ts @@ -32,6 +32,7 @@ import { } from "./utils" import { AlertService } from "services/alert" import { DatabaseService } from "services/database" +import Error404NotFound from "errors/error-404-not-found" export class SpecService { static async getSpec(specName: string): Promise { @@ -85,12 +86,12 @@ export class SpecService { name: fileName, }) if (!openApiSpec) { - throw new Error400BadRequest( + throw new Error404NotFound( "No spec file with the provided name exists.", ) } if (openApiSpec.isAutoGenerated) { - throw new Error400BadRequest("Can't delete auto generated spec.") + throw new Error409Conflict("Can't delete auto generated spec.") } for (let i = 0; i < specEndpoints.length; i++) { const endpoint = specEndpoints[i] diff --git a/frontend/src/components/Endpoint/SpecComponent.tsx b/frontend/src/components/Endpoint/SpecComponent.tsx index 18ed7044..10ec27cf 100644 --- a/frontend/src/components/Endpoint/SpecComponent.tsx +++ b/frontend/src/components/Endpoint/SpecComponent.tsx @@ -3,21 +3,17 @@ import { Box, useColorModeValue, HStack, - InputGroup, - InputLeftElement, - Input, + Heading, Tag, IconButton, Select, } from "@chakra-ui/react" -import debounce from "lodash/debounce" import { saveAs } from "file-saver" import YAML from "yaml" import JsYaml from "js-yaml" import Highlight, { defaultProps } from "prism-react-renderer" import darkTheme from "prism-react-renderer/themes/duotoneDark" import lightTheme from "prism-react-renderer/themes/github" -import { GoSearch } from "@react-icons/all-files/go/GoSearch" import { FiDownload } from "@react-icons/all-files/fi/FiDownload" import { ApiEndpointDetailed } from "@common/types" import { SpecExtension } from "@common/enums" @@ -39,7 +35,6 @@ const SpecComponent: React.FC = ({ endpoint }) => { const [currExtension, setCurrExtension] = useState( endpoint.openapiSpec.extension, ) - const [searchQuery, setSearchQuery] = useState("") const blob = new Blob([specString], { type: EXTENSION_TO_TYPE[currExtension], @@ -67,8 +62,6 @@ const SpecComponent: React.FC = ({ endpoint }) => { saveAs(blob, `${endpoint?.openapiSpec?.name}.${currExtension}`) } - const debounceSearch = debounce(setSearchQuery, 500) - return ( = ({ endpoint }) => { justifyContent="space-between" > - - - - - debounceSearch(e.target.value)} - type="text" - placeholder="Search" - /> - + {endpoint?.openapiSpec?.name} {endpoint?.openapiSpec?.isAutoGenerated && ( - + Generated )} @@ -155,24 +137,9 @@ const SpecComponent: React.FC = ({ endpoint }) => { {i + 1} - {line.map((token, key) => { - const matchedString = - searchQuery && token.content.includes(searchQuery) - const color = matchedString - ? "var(--chakra-colors-orange-100)" - : "transparent" - return ( -
- -
- ) - })} + {line.map((token, key) => ( + + ))} ))}