Skip to content

Commit

Permalink
feat: display OpenAPI spec version
Browse files Browse the repository at this point in the history
Refs #9167
  • Loading branch information
char0n committed Aug 25, 2023
1 parent e3ade63 commit d82ce0d
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 32 deletions.
2 changes: 2 additions & 0 deletions src/core/components/info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class Info extends React.Component {
const Markdown = getComponent("Markdown", true)
const Link = getComponent("Link")
const VersionStamp = getComponent("VersionStamp")
const OpenAPIVersion = getComponent("OpenAPIVersion")
const InfoUrl = getComponent("InfoUrl")
const InfoBasePath = getComponent("InfoBasePath")
const License = getComponent("License")
Expand All @@ -100,6 +101,7 @@ class Info extends React.Component {
<h2 className="title">
{title}
{version && <VersionStamp version={version}></VersionStamp>}
<OpenAPIVersion version="OAS 2.0" />
</h2>
{host || basePath ? (
<InfoBasePath host={host} basePath={basePath} />
Expand Down
17 changes: 17 additions & 0 deletions src/core/components/openapi-version.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @prettier
*/
import React from "react"
import PropTypes from "prop-types"

const OpenApiVersion = ({ version }) => (
<small className="version-stamp">
<pre className="version">{version}</pre>
</small>
)

OpenApiVersion.propTypes = {
version: PropTypes.string.isRequired,
}

export default OpenApiVersion
4 changes: 2 additions & 2 deletions src/core/plugins/oas3/wrap-components/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Markdown from "./markdown"
import AuthItem from "./auth-item"
import VersionStamp from "./version-stamp"
import OpenAPIVersion from "./openapi-version"
import OnlineValidatorBadge from "./online-validator-badge"
import Model from "./model"
import JsonSchema_string from "./json-schema-string"
Expand All @@ -9,7 +9,7 @@ export default {
Markdown,
AuthItem,
JsonSchema_string,
VersionStamp,
OpenAPIVersion,
model: Model,
onlineValidatorBadge: OnlineValidatorBadge,
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,5 @@ import { OAS30ComponentWrapFactory } from "../helpers"

export default OAS30ComponentWrapFactory((props) => {
const { Ori } = props

return (
<span>
<Ori {...props} />
<small className="version-stamp">
<pre className="version">OAS 3.0</pre>
</small>
</span>
)
return <Ori version="OAS 3.0" />
})
2 changes: 2 additions & 0 deletions src/core/plugins/oas31/components/info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const Info = ({ getComponent, specSelectors }) => {
const Markdown = getComponent("Markdown", true)
const Link = getComponent("Link")
const VersionStamp = getComponent("VersionStamp")
const OpenAPIVersion = getComponent("OpenAPIVersion")
const InfoUrl = getComponent("InfoUrl")
const InfoBasePath = getComponent("InfoBasePath")
const License = getComponent("License", true)
Expand All @@ -35,6 +36,7 @@ const Info = ({ getComponent, specSelectors }) => {
<h2 className="title">
{title}
{version && <VersionStamp version={version}></VersionStamp>}
<OpenAPIVersion version="OAS 3.1" />
</h2>

{(host || basePath) && <InfoBasePath host={host} basePath={basePath} />}
Expand Down
2 changes: 0 additions & 2 deletions src/core/plugins/oas31/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import InfoWrapper from "./wrap-components/info"
import ModelWrapper from "./wrap-components/model"
import ModelsWrapper from "./wrap-components/models"
import VersionPragmaFilterWrapper from "./wrap-components/version-pragma-filter"
import VersionStampWrapper from "./wrap-components/version-stamp"
import {
isOAS31 as isOAS31Fn,
createOnlyOAS31Selector as createOnlyOAS31SelectorFn,
Expand Down Expand Up @@ -91,7 +90,6 @@ const OAS31Plugin = ({ fn }) => {
License: LicenseWrapper,
Contact: ContactWrapper,
VersionPragmaFilter: VersionPragmaFilterWrapper,
VersionStamp: VersionStampWrapper,
Model: ModelWrapper,
Models: ModelsWrapper,
JSONSchema202012KeywordDescription:
Expand Down
19 changes: 0 additions & 19 deletions src/core/plugins/oas31/wrap-components/version-stamp.jsx

This file was deleted.

2 changes: 2 additions & 0 deletions src/core/presets/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import Property from "core/components/property"
import TryItOutButton from "core/components/try-it-out-button"
import VersionPragmaFilter from "core/components/version-pragma-filter"
import VersionStamp from "core/components/version-stamp"
import OpenAPIVersion from "core/components/openapi-version"
import DeepLink from "core/components/deep-link"
import SvgAssets from "core/components/svg-assets"
import Markdown from "core/components/providers/markdown"
Expand Down Expand Up @@ -157,6 +158,7 @@ export default function () {
BaseLayout,
VersionPragmaFilter,
VersionStamp,
OpenAPIVersion,
OperationExt,
OperationExtRow,
ParameterExt,
Expand Down

0 comments on commit d82ce0d

Please sign in to comment.