openapi-explorer 0.8.264 → 0.8.268

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.8.264",
3
+ "version": "0.8.268",
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": {
@@ -227,7 +227,7 @@ export default class SchemaTable extends LitElement {
227
227
  </div>
228
228
  <div class='td key-descr'>
229
229
  ${dataType === 'array' ? html`<span class="m-markdown-small">${unsafeHTML(marked(description))}</span>` : ''}
230
- ${schemaDescription ? html`<span class="m-markdown-small">${unsafeHTML(marked(`${schemaTitle ? `**${schemaTitle}:** ` : ''}${schemaDescription}`))}</span>` : ''}
230
+ ${schemaTitle || schemaDescription ? html`<span class="m-markdown-small">${unsafeHTML(marked(`${schemaTitle ? `**${schemaTitle}:** ` : ''}${schemaDescription || ''}`))}</span>` : ''}
231
231
  ${constraint ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Constraints: </span> ${constraint}</div>` : ''}
232
232
  ${defaultValue ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Default: </span>${defaultValue}</div>` : ''}
233
233
  ${allowedValues ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Allowed: </span>${allowedValues}</div>` : ''}
@@ -27,7 +27,7 @@ import advancedSearchStyles from './styles/advanced-search-styles';
27
27
 
28
28
  import { advancedSearch, getCurrentElement, pathIsInSearch, replaceState, sleep } from './utils/common-utils';
29
29
  import ProcessSpec from './utils/spec-parser';
30
- import mainBodyTemplate from './templates/main-body-template';
30
+ import responsiveViewMainBodyTemplate from './templates/responsiveViewMainBodyTemplate';
31
31
  import apiRequestStyles from './styles/api-request-styles';
32
32
  import { checkForAuthToken } from './templates/security-scheme-template';
33
33
 
@@ -180,8 +180,11 @@ export default class OpenApiExplorer extends LitElement {
180
180
  .section-gap.section-tag {
181
181
  border-bottom:1px solid var(--border-color);
182
182
  }
183
+ .method-section-gap {
184
+ padding: 24px 8px 0px 4px;
185
+ }
183
186
  .section-gap {
184
- padding: 0px 4px;
187
+ padding: 24px 0px 0px;
185
188
  }
186
189
  .section-tag-header {
187
190
  position:relative;
@@ -432,7 +435,7 @@ export default class OpenApiExplorer extends LitElement {
432
435
  }
433
436
 
434
437
  render() {
435
- return mainBodyTemplate.call(this);
438
+ return responsiveViewMainBodyTemplate.call(this);
436
439
  }
437
440
 
438
441
  observeExpandedContent() {
@@ -144,7 +144,7 @@ export default function endpointTemplate() {
144
144
  <span @click="${(e) => expandCollapseAll.call(this, e, 'collapse-all')}" style="color:var(--primary-color); cursor: pointer;">Collapse</span>
145
145
  </div>
146
146
  ${(this.resolvedSpec && this.resolvedSpec.tags || []).map((tag) => html`
147
- <div class='regular-font section-gap section-tag ${tag.expanded ? 'expanded' : 'collapsed'}' >
147
+ <div class='regular-font method-section-gap section-tag ${tag.expanded ? 'expanded' : 'collapsed'}' >
148
148
 
149
149
  <div class='section-tag-header' @click="${(e) => toggleTag.call(this, e, tag.elementId)}">
150
150
  <div id='${tag.elementId}' class="sub-title tag" style="color:var(--primary-color)">${tag.name}</div>
@@ -72,7 +72,7 @@ export default function focusedEndpointTemplate() {
72
72
  } else if (focusElId === 'section') {
73
73
  focusedTemplate = html`
74
74
  <section id='section' style="margin-top:24px; margin-bottom:24px;"
75
- class='observe-me ${this.renderStyle === 'read' ? 'section-gap--read-mode' : (this.renderStyle === 'focused' ? 'section-gap--focused-mode' : 'section-gap')}'>
75
+ class='observe-me ${this.renderStyle === 'focused' ? 'section-gap--focused-mode' : 'section-gap'}'>
76
76
  <slot name="custom-section"></slot>
77
77
  </section>`;
78
78
  } else if (focusElId.startsWith('cmp--') && this.showComponents === 'true') {
@@ -12,7 +12,7 @@ function headingRenderer() {
12
12
  export default function overviewTemplate() {
13
13
  return html`
14
14
  <section id="overview" part="section-overview"
15
- class="observe-me ${this.renderStyle === 'read' ? 'section-gap--read-mode' : (this.renderStyle === 'focused' ? 'section-gap--focused-mode' : 'section-gap')}">
15
+ class="observe-me ${this.renderStyle === 'focused' ? 'section-gap--focused-mode' : 'section-gap'}">
16
16
  ${this.resolvedSpec && this.resolvedSpec.info
17
17
  ? html`
18
18
  <slot name="overview">
@@ -12,7 +12,7 @@ import advancedSearchTemplate from './advance-search-template';
12
12
  import SetTheme from '../utils/theme';
13
13
  import ColorUtils from '../utils/color-utils';
14
14
 
15
- export default function mainBodyTemplate() {
15
+ export default function responsiveViewMainBodyTemplate() {
16
16
  const newTheme = {
17
17
  bg1: ColorUtils.isValidHexColor(this.bgColor) ? this.bgColor : '',
18
18
  fg1: ColorUtils.isValidHexColor(this.textColor) ? this.textColor : '',
@@ -57,8 +57,8 @@ export default function mainBodyTemplate() {
57
57
  ${this.showInfo === 'true' ? overviewTemplate.call(this) : ''}
58
58
  ${this.allowServerSelection === 'true' ? serverTemplate.call(this) : ''}
59
59
  ${this.allowAuthentication === 'true' ? securitySchemeTemplate.call(this) : ''}
60
- <section id='section' style="margin-top:24px; margin-bottom:24px;"
61
- class='observe-me ${this.renderStyle === 'read' ? 'section-gap--read-mode' : (this.renderStyle === 'focused' ? 'section-gap--focused-mode' : 'section-gap')}'>
60
+ <section id='section'
61
+ class='observe-me ${this.renderStyle === 'focused' ? 'section-gap--focused-mode' : 'section-gap'}'>
62
62
  <slot name="custom-section"></slot>
63
63
  </section>
64
64
  ${this.renderStyle === 'read'
@@ -298,7 +298,7 @@ export default function securitySchemeTemplate() {
298
298
  }
299
299
  const providedApiKeys = schemes.filter((v) => (v.finalKeyValue));
300
300
  return html`
301
- <section id='auth' part="section-auth" class = 'observe-me ${this.renderStyle === 'read' ? 'section-gap--read-mode' : (this.renderStyle === 'focused' ? 'section-gap--focused-mode' : 'section-gap')}'>
301
+ <section id='auth' part="section-auth" class = 'observe-me ${this.renderStyle === 'focused' ? 'section-gap--focused-mode' : 'section-gap'}'>
302
302
  <slot name="authentication">
303
303
  <div class="section-padding">
304
304
  <div class='sub-title regular-font'>AUTHENTICATION</div>
@@ -5,12 +5,21 @@ import { invalidCharsRegEx } from './common-utils';
5
5
 
6
6
  export default async function ProcessSpec(requiresLookup, specUrlOrObject, serverUrl = '') {
7
7
  let specMeta;
8
+
9
+ // Dynamically resolve non yaml or json files and insert their descriptions where necessary
10
+ function responseInterceptor(val) {
11
+ if (val.ok && val.text && val.parseError && val.parseError.name === 'YAMLException' && (!val.headers['content-type'] || val.headers['content-type'].match('text/plain'))) {
12
+ val.body = val.text;
13
+ }
14
+ return val;
15
+ }
16
+
8
17
  if (requiresLookup) {
9
- specMeta = await SwaggerClient(specUrlOrObject);
18
+ specMeta = await SwaggerClient({ url: specUrlOrObject, responseInterceptor });
10
19
  } else if (typeof specUrlOrObject === 'string') {
11
- specMeta = await SwaggerClient({ spec: yaml.load(specUrlOrObject) });
20
+ specMeta = await SwaggerClient({ spec: yaml.load(specUrlOrObject), responseInterceptor });
12
21
  } else {
13
- specMeta = await SwaggerClient({ spec: specUrlOrObject });
22
+ specMeta = await SwaggerClient({ spec: specUrlOrObject, responseInterceptor });
14
23
  }
15
24
 
16
25
  const jsonParsedSpec = specMeta.spec;