docusaurus-theme-openapi-docs 0.0.0-1158 → 0.0.0-1160

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -105,6 +105,10 @@ function getSchemaEnum(schema) {
105
105
  }
106
106
  }
107
107
  }
108
+ // const is semantically a single-value enum
109
+ if (schema?.const !== undefined) {
110
+ return [schema.const];
111
+ }
108
112
  return undefined;
109
113
  }
110
114
  function ParamOption({ param, label, type, required }) {
@@ -88,11 +88,37 @@ function ParamsItem({ param, ...rest }) {
88
88
  })
89
89
  )
90
90
  );
91
+ const constValue = schema?.const;
91
92
  const renderQualifier = (0, utils_1.guard)(
92
93
  (0, schema_1.getQualifierMessage)(schema),
93
94
  (qualifier) =>
94
95
  react_1.default.createElement(Markdown_1.default, null, qualifier)
95
96
  );
97
+ function renderConstValue() {
98
+ if (constValue === undefined) {
99
+ return undefined;
100
+ }
101
+ const label = (0, Translate_1.translate)({
102
+ id: translationIds_1.OPENAPI_SCHEMA_ITEM.CONSTANT_VALUE,
103
+ message: "Constant value:",
104
+ });
105
+ return react_1.default.createElement(
106
+ "div",
107
+ null,
108
+ react_1.default.createElement("strong", null, label, " "),
109
+ react_1.default.createElement(
110
+ "span",
111
+ null,
112
+ react_1.default.createElement(
113
+ "code",
114
+ null,
115
+ typeof constValue === "string"
116
+ ? constValue
117
+ : JSON.stringify(constValue)
118
+ )
119
+ )
120
+ );
121
+ }
96
122
  const renderDescription = (0, utils_1.guard)(description, (description) =>
97
123
  react_1.default.createElement(Markdown_1.default, null, description)
98
124
  );
@@ -177,6 +203,7 @@ function ParamsItem({ param, ...rest }) {
177
203
  renderDeprecated
178
204
  ),
179
205
  renderQualifier,
206
+ renderConstValue(),
180
207
  renderDescription,
181
208
  renderEnumDescriptions,
182
209
  renderDefaultValue(),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docusaurus-theme-openapi-docs",
3
3
  "description": "OpenAPI theme for Docusaurus.",
4
- "version": "0.0.0-1158",
4
+ "version": "0.0.0-1160",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -38,7 +38,7 @@
38
38
  "@types/postman-collection": "^3.5.11",
39
39
  "@types/react-modal": "^3.16.3",
40
40
  "concurrently": "^9.2.0",
41
- "docusaurus-plugin-openapi-docs": "0.0.0-1158",
41
+ "docusaurus-plugin-openapi-docs": "0.0.0-1160",
42
42
  "docusaurus-plugin-sass": "^0.2.6",
43
43
  "eslint-plugin-prettier": "^5.5.1"
44
44
  },
@@ -82,5 +82,5 @@
82
82
  "engines": {
83
83
  "node": ">=14"
84
84
  },
85
- "gitHead": "4b4edb328eed92cdea67b43309dc44af0b7c457d"
85
+ "gitHead": "9590f36ccddb212cb31943e14654c4a9a6884ec5"
86
86
  }
@@ -48,6 +48,11 @@ export function getSchemaEnum(schema: any): any[] | undefined {
48
48
  }
49
49
  }
50
50
 
51
+ // const is semantically a single-value enum
52
+ if (schema?.const !== undefined) {
53
+ return [schema.const];
54
+ }
55
+
51
56
  return undefined;
52
57
  }
53
58
 
@@ -102,10 +102,34 @@ function ParamsItem({ param, ...rest }: Props) {
102
102
  </span>
103
103
  ));
104
104
 
105
+ const constValue = schema?.const;
106
+
105
107
  const renderQualifier = guard(getQualifierMessage(schema), (qualifier) => (
106
108
  <Markdown>{qualifier}</Markdown>
107
109
  ));
108
110
 
111
+ function renderConstValue() {
112
+ if (constValue === undefined) {
113
+ return undefined;
114
+ }
115
+ const label = translate({
116
+ id: OPENAPI_SCHEMA_ITEM.CONSTANT_VALUE,
117
+ message: "Constant value:",
118
+ });
119
+ return (
120
+ <div>
121
+ <strong>{label} </strong>
122
+ <span>
123
+ <code>
124
+ {typeof constValue === "string"
125
+ ? constValue
126
+ : JSON.stringify(constValue)}
127
+ </code>
128
+ </span>
129
+ </div>
130
+ );
131
+ }
132
+
109
133
  const renderDescription = guard(description, (description) => (
110
134
  <Markdown>{description}</Markdown>
111
135
  ));
@@ -173,6 +197,7 @@ function ParamsItem({ param, ...rest }: Props) {
173
197
  {renderDeprecated}
174
198
  </span>
175
199
  {renderQualifier}
200
+ {renderConstValue()}
176
201
  {renderDescription}
177
202
  {renderEnumDescriptions}
178
203
  {renderDefaultValue()}