@stoplight/elements-core 8.3.1 → 8.3.2

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.
Files changed (4) hide show
  1. package/index.esm.js +18 -12
  2. package/index.js +18 -12
  3. package/index.mjs +18 -12
  4. package/package.json +2 -2
package/index.esm.js CHANGED
@@ -2546,42 +2546,43 @@ const oauthFlowNames = {
2546
2546
  function getDefaultDescription(scheme) {
2547
2547
  switch (scheme.type) {
2548
2548
  case 'apiKey':
2549
- return getApiKeyDescription(scheme.in, scheme.name);
2549
+ return getApiKeyDescription(scheme);
2550
2550
  case 'http':
2551
2551
  switch (scheme.scheme) {
2552
2552
  case 'basic':
2553
- return getBasicAuthDescription();
2553
+ return getBasicAuthDescription(scheme);
2554
2554
  case 'bearer':
2555
- return getBearerAuthDescription();
2555
+ return getBearerAuthDescription(scheme);
2556
2556
  case 'digest':
2557
- return getDigestAuthDescription();
2557
+ return getDigestAuthDescription(scheme);
2558
2558
  }
2559
2559
  case 'oauth2':
2560
2560
  return getOAuthDescription(scheme);
2561
2561
  }
2562
2562
  return '';
2563
2563
  }
2564
- function getApiKeyDescription(inProperty, name) {
2564
+ function getApiKeyDescription(scheme) {
2565
+ const { in: inProperty, name } = scheme;
2565
2566
  return `An API key is a token that you provide when making API calls. Include the token in a ${inProperty} parameter called \`${name}\`.
2566
2567
 
2567
- Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}`;
2568
+ Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}${getSecuritySchemeRoles(scheme)}`;
2568
2569
  }
2569
- function getBasicAuthDescription() {
2570
+ function getBasicAuthDescription(schema) {
2570
2571
  return `Basic authentication is a simple authentication scheme built into the HTTP protocol.
2571
2572
  To use it, send your HTTP requests with an Authorization header that contains the word Basic
2572
2573
  followed by a space and a base64-encoded string \`username:password\`.
2573
2574
 
2574
- Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\``;
2575
+ Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\`${getSecuritySchemeRoles(schema)}`;
2575
2576
  }
2576
- function getBearerAuthDescription() {
2577
+ function getBearerAuthDescription(schema) {
2577
2578
  return `Provide your bearer token in the Authorization header when making requests to protected resources.
2578
2579
 
2579
- Example: \`Authorization: Bearer 123\``;
2580
+ Example: \`Authorization: Bearer 123\`${getSecuritySchemeRoles(schema)}`;
2580
2581
  }
2581
- function getDigestAuthDescription() {
2582
+ function getDigestAuthDescription(schema) {
2582
2583
  return `Provide your encrypted digest scheme data in the Authorization header when making requests to protected resources.
2583
2584
 
2584
- Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\``;
2585
+ Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\`${getSecuritySchemeRoles(schema)}`;
2585
2586
  }
2586
2587
  function getOAuthDescription(scheme) {
2587
2588
  const flows = keys(scheme.flows);
@@ -2604,6 +2605,11 @@ function getOAuthFlowDescription(title, flow) {
2604
2605
  ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
2605
2606
  }
2606
2607
  return description;
2608
+ }
2609
+ function getSecuritySchemeRoles(scheme) {
2610
+ var _a;
2611
+ const scopes = (_a = scheme.extensions) === null || _a === void 0 ? void 0 : _a['x-scopes'];
2612
+ return Array.isArray(scopes) ? `\n\nRoles: ${scopes.map(scope => `\`${scope}\``).join(', ')}` : '';
2607
2613
  }
2608
2614
 
2609
2615
  const PanelContent = ({ schemes }) => {
package/index.js CHANGED
@@ -2607,42 +2607,43 @@ const oauthFlowNames = {
2607
2607
  function getDefaultDescription(scheme) {
2608
2608
  switch (scheme.type) {
2609
2609
  case 'apiKey':
2610
- return getApiKeyDescription(scheme.in, scheme.name);
2610
+ return getApiKeyDescription(scheme);
2611
2611
  case 'http':
2612
2612
  switch (scheme.scheme) {
2613
2613
  case 'basic':
2614
- return getBasicAuthDescription();
2614
+ return getBasicAuthDescription(scheme);
2615
2615
  case 'bearer':
2616
- return getBearerAuthDescription();
2616
+ return getBearerAuthDescription(scheme);
2617
2617
  case 'digest':
2618
- return getDigestAuthDescription();
2618
+ return getDigestAuthDescription(scheme);
2619
2619
  }
2620
2620
  case 'oauth2':
2621
2621
  return getOAuthDescription(scheme);
2622
2622
  }
2623
2623
  return '';
2624
2624
  }
2625
- function getApiKeyDescription(inProperty, name) {
2625
+ function getApiKeyDescription(scheme) {
2626
+ const { in: inProperty, name } = scheme;
2626
2627
  return `An API key is a token that you provide when making API calls. Include the token in a ${inProperty} parameter called \`${name}\`.
2627
2628
 
2628
- Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}`;
2629
+ Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}${getSecuritySchemeRoles(scheme)}`;
2629
2630
  }
2630
- function getBasicAuthDescription() {
2631
+ function getBasicAuthDescription(schema) {
2631
2632
  return `Basic authentication is a simple authentication scheme built into the HTTP protocol.
2632
2633
  To use it, send your HTTP requests with an Authorization header that contains the word Basic
2633
2634
  followed by a space and a base64-encoded string \`username:password\`.
2634
2635
 
2635
- Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\``;
2636
+ Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\`${getSecuritySchemeRoles(schema)}`;
2636
2637
  }
2637
- function getBearerAuthDescription() {
2638
+ function getBearerAuthDescription(schema) {
2638
2639
  return `Provide your bearer token in the Authorization header when making requests to protected resources.
2639
2640
 
2640
- Example: \`Authorization: Bearer 123\``;
2641
+ Example: \`Authorization: Bearer 123\`${getSecuritySchemeRoles(schema)}`;
2641
2642
  }
2642
- function getDigestAuthDescription() {
2643
+ function getDigestAuthDescription(schema) {
2643
2644
  return `Provide your encrypted digest scheme data in the Authorization header when making requests to protected resources.
2644
2645
 
2645
- Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\``;
2646
+ Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\`${getSecuritySchemeRoles(schema)}`;
2646
2647
  }
2647
2648
  function getOAuthDescription(scheme) {
2648
2649
  const flows = keys__default["default"](scheme.flows);
@@ -2665,6 +2666,11 @@ function getOAuthFlowDescription(title, flow) {
2665
2666
  ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
2666
2667
  }
2667
2668
  return description;
2669
+ }
2670
+ function getSecuritySchemeRoles(scheme) {
2671
+ var _a;
2672
+ const scopes = (_a = scheme.extensions) === null || _a === void 0 ? void 0 : _a['x-scopes'];
2673
+ return Array.isArray(scopes) ? `\n\nRoles: ${scopes.map(scope => `\`${scope}\``).join(', ')}` : '';
2668
2674
  }
2669
2675
 
2670
2676
  const PanelContent = ({ schemes }) => {
package/index.mjs CHANGED
@@ -2546,42 +2546,43 @@ const oauthFlowNames = {
2546
2546
  function getDefaultDescription(scheme) {
2547
2547
  switch (scheme.type) {
2548
2548
  case 'apiKey':
2549
- return getApiKeyDescription(scheme.in, scheme.name);
2549
+ return getApiKeyDescription(scheme);
2550
2550
  case 'http':
2551
2551
  switch (scheme.scheme) {
2552
2552
  case 'basic':
2553
- return getBasicAuthDescription();
2553
+ return getBasicAuthDescription(scheme);
2554
2554
  case 'bearer':
2555
- return getBearerAuthDescription();
2555
+ return getBearerAuthDescription(scheme);
2556
2556
  case 'digest':
2557
- return getDigestAuthDescription();
2557
+ return getDigestAuthDescription(scheme);
2558
2558
  }
2559
2559
  case 'oauth2':
2560
2560
  return getOAuthDescription(scheme);
2561
2561
  }
2562
2562
  return '';
2563
2563
  }
2564
- function getApiKeyDescription(inProperty, name) {
2564
+ function getApiKeyDescription(scheme) {
2565
+ const { in: inProperty, name } = scheme;
2565
2566
  return `An API key is a token that you provide when making API calls. Include the token in a ${inProperty} parameter called \`${name}\`.
2566
2567
 
2567
- Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}`;
2568
+ Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}${getSecuritySchemeRoles(scheme)}`;
2568
2569
  }
2569
- function getBasicAuthDescription() {
2570
+ function getBasicAuthDescription(schema) {
2570
2571
  return `Basic authentication is a simple authentication scheme built into the HTTP protocol.
2571
2572
  To use it, send your HTTP requests with an Authorization header that contains the word Basic
2572
2573
  followed by a space and a base64-encoded string \`username:password\`.
2573
2574
 
2574
- Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\``;
2575
+ Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\`${getSecuritySchemeRoles(schema)}`;
2575
2576
  }
2576
- function getBearerAuthDescription() {
2577
+ function getBearerAuthDescription(schema) {
2577
2578
  return `Provide your bearer token in the Authorization header when making requests to protected resources.
2578
2579
 
2579
- Example: \`Authorization: Bearer 123\``;
2580
+ Example: \`Authorization: Bearer 123\`${getSecuritySchemeRoles(schema)}`;
2580
2581
  }
2581
- function getDigestAuthDescription() {
2582
+ function getDigestAuthDescription(schema) {
2582
2583
  return `Provide your encrypted digest scheme data in the Authorization header when making requests to protected resources.
2583
2584
 
2584
- Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\``;
2585
+ Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\`${getSecuritySchemeRoles(schema)}`;
2585
2586
  }
2586
2587
  function getOAuthDescription(scheme) {
2587
2588
  const flows = keys(scheme.flows);
@@ -2604,6 +2605,11 @@ function getOAuthFlowDescription(title, flow) {
2604
2605
  ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
2605
2606
  }
2606
2607
  return description;
2608
+ }
2609
+ function getSecuritySchemeRoles(scheme) {
2610
+ var _a;
2611
+ const scopes = (_a = scheme.extensions) === null || _a === void 0 ? void 0 : _a['x-scopes'];
2612
+ return Array.isArray(scopes) ? `\n\nRoles: ${scopes.map(scope => `\`${scope}\``).join(', ')}` : '';
2607
2613
  }
2608
2614
 
2609
2615
  const PanelContent = ({ schemes }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "8.3.1",
3
+ "version": "8.3.2",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",
@@ -24,7 +24,7 @@
24
24
  "react-dom": ">=16.8"
25
25
  },
26
26
  "dependencies": {
27
- "@stoplight/http-spec": "^7.0.3",
27
+ "@stoplight/http-spec": "^7.1.0",
28
28
  "@stoplight/json": "^3.21.0",
29
29
  "@stoplight/json-schema-ref-parser": "^9.2.7",
30
30
  "@stoplight/json-schema-sampler": "0.3.0",