Skip to content

Commit

Permalink
Merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
andremartinssw committed Jan 8, 2024
2 parents eda7dd3 + 1f4e8ac commit 3176b41
Show file tree
Hide file tree
Showing 17 changed files with 286 additions and 22 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.7.2 (Dec 21, 2023)

Enhancements and bug fixes

- Fix bash syntax highlighting ([#274](https://github.com/cloud-annotations/docusaurus-openapi/pull/274))

## 0.7.1 (Dec 18, 2023)

High-level enhancements
Expand Down
9 changes: 7 additions & 2 deletions demo/examples/petstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ paths:
schema:
type: string
format: binary
description: |
This description contains <a href="https://www.w3.org/html/">HTML</a><br />
Cat pics plz
/pet/findByStatus:
get:
tags:
Expand Down Expand Up @@ -838,13 +841,15 @@ paths:
parameters:
- name: username
in: query
description: The user name for login
description: |
This description contains <a href="https://www.w3.org/html/">HTML</a><br />The user name for login
required: true
schema:
type: string
- name: password
in: query
description: The password for login in clear text
description: |
This description contains [markdown](https://www.markdownguide.org/)<br />The password for login in clear text
required: true
schema:
type: string
Expand Down
4 changes: 2 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "demo",
"version": "0.7.1",
"version": "0.7.2",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand All @@ -17,7 +17,7 @@
"@docusaurus/core": "^3.0.0",
"@svgr/webpack": "^5.5.0",
"clsx": "^1.2.1",
"docusaurus-preset-openapi": "^0.7.1",
"docusaurus-preset-openapi": "^0.7.2",
"file-loader": "^6.2.0",
"prism-react-renderer": "^2.1.0",
"react": "^18.0.0",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.7.1",
"version": "0.7.2",
"npmClient": "yarn",
"useWorkspaces": true
}
2 changes: 1 addition & 1 deletion packages/create-docusaurus-openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-docusaurus-openapi",
"version": "0.7.1",
"version": "0.7.2",
"description": "Create Docusaurus apps easily.",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docusaurus-plugin-openapi",
"description": "OpenAPI plugin for Docusaurus.",
"version": "0.7.1",
"version": "0.7.2",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-proxy/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docusaurus-plugin-proxy",
"description": "A dev server proxy for Docusaurus.",
"version": "0.7.1",
"version": "0.7.2",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand Down
8 changes: 4 additions & 4 deletions packages/docusaurus-preset-openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docusaurus-preset-openapi",
"description": "OpenAPI preset for Docusaurus.",
"version": "0.7.1",
"version": "0.7.2",
"license": "MIT",
"keywords": [
"openapi",
Expand Down Expand Up @@ -32,9 +32,9 @@
},
"dependencies": {
"@docusaurus/preset-classic": "^3.0.0",
"docusaurus-plugin-openapi": "^0.7.1",
"docusaurus-plugin-proxy": "^0.7.1",
"docusaurus-theme-openapi": "^0.7.1"
"docusaurus-plugin-openapi": "^0.7.2",
"docusaurus-plugin-proxy": "^0.7.2",
"docusaurus-theme-openapi": "^0.7.2"
},
"peerDependencies": {
"react": "^18.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-template-openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docusaurus-template-openapi",
"version": "0.7.1",
"version": "0.7.2",
"keywords": [
"react",
"create-docusaurus",
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-template-openapi/template.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"package": {
"name": "demo",
"version": "0.7.1",
"version": "0.7.2",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand All @@ -16,7 +16,7 @@
},
"dependencies": {
"@docusaurus/core": "^3.0.0",
"docusaurus-preset-openapi": "0.7.1",
"docusaurus-preset-openapi": "0.7.2",
"@mdx-js/react": "^3.0.0",
"clsx": "^1.2.1",
"prism-react-renderer": "^2.1.0",
Expand Down
7 changes: 5 additions & 2 deletions packages/docusaurus-theme-openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docusaurus-theme-openapi",
"description": "OpenAPI theme for Docusaurus.",
"version": "0.7.1",
"version": "0.7.2",
"license": "MIT",
"publishConfig": {
"access": "public"
Expand Down Expand Up @@ -42,9 +42,10 @@
"buffer": "^6.0.3",
"clsx": "^1.2.1",
"crypto-js": "^4.1.1",
"docusaurus-plugin-openapi": "^0.7.1",
"docusaurus-plugin-openapi": "^0.7.2",
"immer": "^9.0.7",
"lodash": "^4.17.20",
"marked": "^11.0.0",
"monaco-editor": "^0.31.1",
"postman-code-generators": "^1.0.0",
"postman-collection": "^4.1.0",
Expand All @@ -53,6 +54,8 @@
"react-magic-dropzone": "^1.0.1",
"react-redux": "^7.2.0",
"redux-devtools-extension": "^2.13.8",
"refractor": "^4.8.1",
"striptags": "^3.2.0",
"webpack": "^5.88.1"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ import type { Props } from "@theme/ApiDemoPanel/Curl";
import clsx from "clsx";
// @ts-ignore
import codegen from "postman-code-generators";
import { Highlight } from "prism-react-renderer";
import { Highlight, Prism } from "prism-react-renderer";
import bashLang from "refractor/lang/bash";

import buildPostmanRequest from "./../buildPostmanRequest";
import FloatingButton from "./../FloatingButton";
import styles from "./styles.module.css";
import { useTypedSelector } from "../hooks";

bashLang(Prism);

interface Language {
tabName: string;
highlight: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import MagicDropzone from "react-magic-dropzone";

import styles from "./styles.module.css";
import FloatingButton from "../FloatingButton";
import { stripText } from "../text";

type PreviewFile = { preview: string } & File;

Expand Down Expand Up @@ -107,7 +108,7 @@ function FormFileUpload({ placeholder, onChange }: Props) {
<RenderPreview file={file} />
</>
) : (
<div className={styles.dropzoneContent}>{placeholder}</div>
<div className={styles.dropzoneContent}>{stripText(placeholder)}</div>
)}
</MagicDropzone>
</FloatingButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import React from "react";

import styles from "./styles.module.css";
import { stripText } from "../text";

interface Props {
value?: string;
Expand All @@ -21,7 +22,7 @@ function FormTextInput({ value, placeholder, password, onChange }: Props) {
<input
className={styles.input}
type={password ? "password" : "text"}
placeholder={placeholder}
placeholder={stripText(placeholder)}
value={value}
onChange={onChange}
autoComplete="off"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* ============================================================================
* Copyright (c) Cloud Annotations
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* ========================================================================== */

import { stripText } from "./text";

describe("stripText function", () => {
it("should return empty string when passed undefined", () => {
expect(stripText(undefined)).toBe("");
});

it("should strip markdown", () => {
expect(
stripText(
"**This** description contains [markdown](https://www.markdownguide.org/)"
)
).toBe("This description contains markdown");
});

it("should strip HTML", () => {
expect(
stripText(
'<strong>This</strong> description contains <a href="https://www.w3.org/html/">HTML</a>'
)
).toBe("This description contains HTML");
});

it("should replace newlines with space", () => {
expect(stripText("one\ntwo\n\nthree")).toBe("one two three");
});

it("should insert whitespace between HTML elements", () => {
expect(
stripText("<div><div>one</div></div><p>two</p><p>three</p><br />four")
).toBe("one two three four");
});
});
19 changes: 19 additions & 0 deletions packages/docusaurus-theme-openapi/src/theme/ApiDemoPanel/text.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* ============================================================================
* Copyright (c) Cloud Annotations
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* ========================================================================== */

import { marked } from "marked";
import striptags from "striptags";

export function stripText(text?: string): string {
if (text === undefined) {
return "";
}
const renderer = new marked.TextRenderer();
marked.use({ silent: true, renderer });
const parsedMarkdown = marked.parse(text, { async: false }) as string;
return striptags(parsedMarkdown, [], " ").replace(/\s+/g, " ").trim();
}
Loading

0 comments on commit 3176b41

Please sign in to comment.