docusaurus-theme-openapi-docs 0.0.0-1005 → 0.0.0-1006

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.
@@ -114,10 +114,7 @@ const AnyOneOf = ({ schema, schemaType }) => {
114
114
  react_1.default.createElement(
115
115
  TabItem_1.default,
116
116
  { key: index, label: label, value: `${index}-item-properties` },
117
- (["string", "number", "integer", "boolean"].includes(
118
- anyOneSchema.type
119
- ) ||
120
- anyOneSchema.const) &&
117
+ (isPrimitive(anyOneSchema) || anyOneSchema.const) &&
121
118
  react_1.default.createElement(SchemaItem_1.default, {
122
119
  collapsible: false,
123
120
  name: undefined,
@@ -884,3 +881,13 @@ const SchemaNode = ({ schema, schemaType }) => {
884
881
  return renderChildren(schema, schemaType);
885
882
  };
886
883
  exports.default = SchemaNode;
884
+ const PRIMITIVE_TYPES = {
885
+ string: true,
886
+ number: true,
887
+ integer: true,
888
+ boolean: true,
889
+ null: true,
890
+ };
891
+ const isPrimitive = (schema) => {
892
+ return PRIMITIVE_TYPES[schema.type];
893
+ };
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-1005",
4
+ "version": "0.0.0-1006",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -36,7 +36,7 @@
36
36
  "@types/lodash": "^4.14.176",
37
37
  "@types/pako": "^2.0.3",
38
38
  "concurrently": "^5.2.0",
39
- "docusaurus-plugin-openapi-docs": "0.0.0-1005",
39
+ "docusaurus-plugin-openapi-docs": "0.0.0-1006",
40
40
  "docusaurus-plugin-sass": "^0.2.3",
41
41
  "eslint-plugin-prettier": "^5.0.1"
42
42
  },
@@ -79,5 +79,5 @@
79
79
  "engines": {
80
80
  "node": ">=14"
81
81
  },
82
- "gitHead": "4263fa2f5bae006b1d7328a0f16af378786fed47"
82
+ "gitHead": "e73c0b0cead279cb3771b546adc1caebabf336ae"
83
83
  }
@@ -21,7 +21,10 @@ import {
21
21
  getQualifierMessage,
22
22
  getSchemaName,
23
23
  } from "docusaurus-plugin-openapi-docs/lib/markdown/schema";
24
- import { SchemaObject } from "docusaurus-plugin-openapi-docs/lib/openapi/types";
24
+ import {
25
+ SchemaObject,
26
+ SchemaType,
27
+ } from "docusaurus-plugin-openapi-docs/lib/openapi/types";
25
28
  import isEmpty from "lodash/isEmpty";
26
29
 
27
30
  // eslint-disable-next-line import/no-extraneous-dependencies
@@ -122,10 +125,7 @@ const AnyOneOf: React.FC<SchemaProps> = ({ schema, schemaType }) => {
122
125
  value={`${index}-item-properties`}
123
126
  >
124
127
  {/* Handle primitive types directly */}
125
- {(["string", "number", "integer", "boolean"].includes(
126
- anyOneSchema.type
127
- ) ||
128
- anyOneSchema.const) && (
128
+ {(isPrimitive(anyOneSchema) || anyOneSchema.const) && (
129
129
  <SchemaItem
130
130
  collapsible={false}
131
131
  name={undefined}
@@ -938,3 +938,17 @@ const SchemaNode: React.FC<SchemaProps> = ({ schema, schemaType }) => {
938
938
  };
939
939
 
940
940
  export default SchemaNode;
941
+
942
+ type PrimitiveSchemaType = Exclude<SchemaType, "object" | "array">;
943
+
944
+ const PRIMITIVE_TYPES: Record<PrimitiveSchemaType, true> = {
945
+ string: true,
946
+ number: true,
947
+ integer: true,
948
+ boolean: true,
949
+ null: true,
950
+ } as const;
951
+
952
+ const isPrimitive = (schema: SchemaObject) => {
953
+ return PRIMITIVE_TYPES[schema.type as PrimitiveSchemaType];
954
+ };