openapi-explorer 0.6.222 → 0.6.223

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-explorer",
3
- "version": "0.6.222",
3
+ "version": "0.6.223",
4
4
  "description": "OpenAPI Explorer - API viewer with dynamically generated components, documentation, and interaction console",
5
5
  "author": "Rhosys Developers <developers@rhosys.ch>",
6
6
  "repository": {
@@ -145,8 +145,8 @@ export default class ApiRequest extends LitElement {
145
145
  tableRows.push(html`
146
146
  <tr>
147
147
  <td style="width:160px; min-width:50px;">
148
- <div class="param-name">
149
- ${param.required ? html`<span style='color:var(--red)'>*</span>` : ''}${param.name}
148
+ <div class="param-name ${paramSchema.deprecated ? 'deprecated' : ''}">
149
+ ${param.name}${!paramSchema.deprecated && param.required ? html`<span style='color:var(--red);'>*</span>` : ''}
150
150
  </div>
151
151
  <div class="param-type">
152
152
  ${paramSchema.type === 'array'
@@ -497,11 +497,8 @@ export default class ApiRequest extends LitElement {
497
497
  formDataTableRows.push(html`
498
498
  <tr>
499
499
  <td style="width:160px; min-width:100px;">
500
- <div class="param-name">
501
- ${fieldSchema.required
502
- ? html`<span style='color:var(--red);'>*</span>${fieldName}`
503
- : html`${fieldName}`
504
- }
500
+ <div class="param-name ${fieldSchema.deprecated ? 'deprecated' : ''}">
501
+ ${fieldName}${!fieldSchema.deprecated && (schema.required?.includes(fieldName) || fieldSchema.required) ? html`<span style='color:var(--red);'>*</span>` : ''}
505
502
  </div>
506
503
  <div class="param-type">${paramSchema.type}</div>
507
504
  </td>
@@ -1004,11 +1001,15 @@ export default class ApiRequest extends LitElement {
1004
1001
  const exampleTextAreaEl = requestPanelEl.querySelector('.request-body-param-user-input');
1005
1002
  if (exampleTextAreaEl && exampleTextAreaEl.value) {
1006
1003
  fetchOptions.body = exampleTextAreaEl.value;
1007
- // curlData = ` -d ${JSON.stringify(exampleTextAreaEl.value.replace(/(\r\n|\n|\r)/gm, '')).replace(/\\"/g, "'")} \\ \n`;
1008
- try {
1009
- curlData = ` -d '${JSON.stringify(JSON.parse(exampleTextAreaEl.value))}' \\\n`;
1010
- } catch (err) {
1011
- curlData = ` -d '${exampleTextAreaEl.value.replace(/(\r\n|\n|\r)/gm, '')}' \\\n`;
1004
+ if (requestBodyType.includes('json')) {
1005
+ try {
1006
+ curlData = ` -d '${JSON.stringify(JSON.parse(exampleTextAreaEl.value))}' \\\n`;
1007
+ } catch (err) { /* Ignore unparseable JSON */ }
1008
+ }
1009
+
1010
+ if (!curlData) {
1011
+ // Save single quotes wrapped => 'text' => `"'"text"'"`
1012
+ curlData = ` -d '${exampleTextAreaEl.value.replace(/'/g, '\'"\'"\'')}' \\\n`;
1012
1013
  }
1013
1014
  }
1014
1015
  }
@@ -19,6 +19,9 @@ export default css`
19
19
  color: var(--fg);
20
20
  font-family: var(--font-mono);
21
21
  }
22
+ .api-request .param-name.deprecated {
23
+ text-decoration: line-through;
24
+ }
22
25
  .api-request .param-type {
23
26
  color: var(--light-fg);
24
27
  font-family: var(--font-regular);
@@ -631,7 +631,8 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
631
631
  }
632
632
 
633
633
  /* Create Example object */
634
- export function generateExample(examples, example, schema, mimeType, includeReadOnly = true, includeWriteOnly = true, outputType) {
634
+ export function generateExample(examples, example, schema, rawMimeType, includeReadOnly = true, includeWriteOnly = true, outputType) {
635
+ const mimeType = rawMimeType || 'application/json';
635
636
  const finalExamples = [];
636
637
  // First check if examples is provided
637
638
  if (examples) {
@@ -281,6 +281,18 @@ function groupByTags(openApiSpec, generateMissingTags = false) {
281
281
  finalParameters = pathOrHookObj.parameters ? pathOrHookObj.parameters.slice(0) : [];
282
282
  }
283
283
 
284
+ // Remove bad callbacks
285
+ if (pathOrHookObj.callbacks) {
286
+ for (const [callbackName, callbackConfig] of Object.entries(pathOrHookObj.callbacks)) {
287
+ const originalCallbackEntries = Object.entries(callbackConfig);
288
+ const filteredCallbacks = originalCallbackEntries.filter((entry) => typeof entry[1] === 'object') || [];
289
+ pathOrHookObj.callbacks[callbackName] = Object.fromEntries(filteredCallbacks);
290
+ if (filteredCallbacks.length !== originalCallbackEntries.length) {
291
+ console.warn(`OpenAPI Explorer: Invalid Callback found in ${callbackName}`); // eslint-disable-line no-console
292
+ }
293
+ }
294
+ }
295
+
284
296
  // Update Responses
285
297
  tagObj.paths.push({
286
298
  show: true,