docusaurus-plugin-openapi-docs 0.0.0-446 → 0.0.0-448

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.
@@ -60,15 +60,17 @@ function sampleResponseFromProp(name, prop, obj) {
60
60
  }
61
61
  const sampleResponseFromSchema = (schema = {}) => {
62
62
  try {
63
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
63
64
  let { type, example, allOf, oneOf, anyOf, properties, items } = schema;
64
- if (example !== undefined) {
65
- return example;
66
- }
65
+ // TODO: determine if we should always ignore the example when creating from schema
66
+ // if (example !== undefined) {
67
+ // return example;
68
+ // }
67
69
  if (allOf) {
68
70
  const { mergedSchemas } = (0, createResponseSchema_1.mergeAllOf)(allOf);
69
71
  if (mergedSchemas.properties) {
70
72
  for (const [key, value] of Object.entries(mergedSchemas.properties)) {
71
- if (value.readOnly && value.readOnly === true) {
73
+ if (value.writeOnly && value.writeOnly === true) {
72
74
  delete mergedSchemas.properties[key];
73
75
  }
74
76
  }
@@ -99,14 +101,14 @@ const sampleResponseFromSchema = (schema = {}) => {
99
101
  for (let [name, prop] of Object.entries(properties !== null && properties !== void 0 ? properties : {})) {
100
102
  if (prop.properties) {
101
103
  for (const [key, value] of Object.entries(prop.properties)) {
102
- if (value.readOnly && value.readOnly === true) {
104
+ if (value.writeOnly && value.writeOnly === true) {
103
105
  delete prop.properties[key];
104
106
  }
105
107
  }
106
108
  }
107
109
  if (prop.items && prop.items.properties) {
108
110
  for (const [key, value] of Object.entries(prop.items.properties)) {
109
- if (value.readOnly && value.readOnly === true) {
111
+ if (value.writeOnly && value.writeOnly === true) {
110
112
  delete prop.items.properties[key];
111
113
  }
112
114
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-openapi-docs",
3
3
  "description": "OpenAPI plugin for Docusaurus.",
4
- "version": "0.0.0-446",
4
+ "version": "0.0.0-448",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -68,5 +68,5 @@
68
68
  "engines": {
69
69
  "node": ">=14"
70
70
  },
71
- "gitHead": "4369c1e6f8cec59e27f7f250835b88b01a14d058"
71
+ "gitHead": "9ca7fd6049b1e78fb047b1d99ed0bd61df2ffb10"
72
72
  }
@@ -77,18 +77,20 @@ function sampleResponseFromProp(name: string, prop: any, obj: any): any {
77
77
 
78
78
  export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
79
79
  try {
80
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
80
81
  let { type, example, allOf, oneOf, anyOf, properties, items } = schema;
81
82
 
82
- if (example !== undefined) {
83
- return example;
84
- }
83
+ // TODO: determine if we should always ignore the example when creating from schema
84
+ // if (example !== undefined) {
85
+ // return example;
86
+ // }
85
87
 
86
88
  if (allOf) {
87
89
  const { mergedSchemas }: { mergedSchemas: SchemaObject } =
88
90
  mergeAllOf(allOf);
89
91
  if (mergedSchemas.properties) {
90
92
  for (const [key, value] of Object.entries(mergedSchemas.properties)) {
91
- if (value.readOnly && value.readOnly === true) {
93
+ if (value.writeOnly && value.writeOnly === true) {
92
94
  delete mergedSchemas.properties[key];
93
95
  }
94
96
  }
@@ -121,7 +123,7 @@ export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
121
123
  for (let [name, prop] of Object.entries(properties ?? {})) {
122
124
  if (prop.properties) {
123
125
  for (const [key, value] of Object.entries(prop.properties)) {
124
- if (value.readOnly && value.readOnly === true) {
126
+ if (value.writeOnly && value.writeOnly === true) {
125
127
  delete prop.properties[key];
126
128
  }
127
129
  }
@@ -129,7 +131,7 @@ export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
129
131
 
130
132
  if (prop.items && prop.items.properties) {
131
133
  for (const [key, value] of Object.entries(prop.items.properties)) {
132
- if (value.readOnly && value.readOnly === true) {
134
+ if (value.writeOnly && value.writeOnly === true) {
133
135
  delete prop.items.properties[key];
134
136
  }
135
137
  }