rapidoc 9.1.3 → 9.1.4

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 (52) hide show
  1. package/dist/index.html +1 -1
  2. package/dist/index.html.gz +0 -0
  3. package/dist/rapidoc-min.js +2 -2
  4. package/dist/rapidoc-min.js.LICENSE.txt +17 -1
  5. package/dist/rapidoc-min.js.LICENSE.txt.gz +0 -0
  6. package/dist/rapidoc-min.js.gz +0 -0
  7. package/dist/report.html +6 -5
  8. package/docker/Dockerfile +5 -5
  9. package/docs/api.html +12 -5
  10. package/docs/examples/dynamic-query-params.html +1 -0
  11. package/docs/examples/readwrite.html +40 -0
  12. package/docs/examples.html +3 -2
  13. package/docs/index.html +2 -2
  14. package/docs/list.html +6 -2
  15. package/docs/quickstart.html +1 -1
  16. package/docs/rapidoc-min.js +2 -2
  17. package/docs/specs/code-highlight.yaml +1 -1
  18. package/docs/specs/data-types.yaml +0 -1
  19. package/docs/specs/examples.yaml +11 -0
  20. package/docs/specs/petstore_extended.yaml +1 -1
  21. package/docs/specs/readwrite.yaml +90 -0
  22. package/docs/specs/temp.json +24 -105
  23. package/docs/specs/temp.yaml +20 -282
  24. package/docs/welcome.html +3 -3
  25. package/index.html +8 -5
  26. package/package.json +22 -21
  27. package/src/components/api-request.js +78 -41
  28. package/src/components/api-response.js +10 -10
  29. package/src/components/schema-table.js +51 -14
  30. package/src/components/schema-tree.js +59 -18
  31. package/src/components/tag-input.js +8 -1
  32. package/src/json-schema-viewer.js +1 -1
  33. package/src/rapidoc-mini.js +5 -1
  34. package/src/rapidoc.js +5 -1
  35. package/src/styles/font-styles.js +3 -2
  36. package/src/styles/nav-styles.js +2 -2
  37. package/src/templates/components-template.js +5 -5
  38. package/src/templates/endpoint-template.js +1 -1
  39. package/src/templates/expanded-endpoint-template.js +1 -1
  40. package/src/templates/focused-endpoint-template.js +1 -1
  41. package/src/templates/header-template.js +1 -1
  42. package/src/templates/json-schema-viewer-template.js +8 -8
  43. package/src/templates/main-body-template.js +4 -1
  44. package/src/templates/navbar-template.js +2 -2
  45. package/src/templates/overview-template.js +5 -2
  46. package/src/templates/security-scheme-template.js +48 -13
  47. package/src/templates/server-template.js +1 -1
  48. package/src/utils/common-utils.js +2 -1
  49. package/src/utils/schema-utils.js +14 -9
  50. package/src/utils/spec-parser.js +3 -3
  51. package/webpack.config.js +1 -0
  52. package/docs/specs/tenants.json +0 -12
@@ -389,10 +389,12 @@ export function schemaToSampleObj(schema, config = { }) {
389
389
  const oneOfSamples = schemaToSampleObj(schema.oneOf[key], config);
390
390
  for (const sampleKey in oneOfSamples) {
391
391
  // 2. In the final example include a one-of item along with properties
392
- const finalExample = Object.assign(oneOfSamples[sampleKey], objWithSchemaProps);
393
- obj[`example-${i}`] = finalExample;
394
- addSchemaInfoToExample(schema.oneOf[key], obj[`example-${i}`]);
395
- i++;
392
+ if (oneOfSamples[sampleKey] === null) {
393
+ const finalExample = Object.assign(oneOfSamples[sampleKey], objWithSchemaProps);
394
+ obj[`example-${i}`] = finalExample;
395
+ addSchemaInfoToExample(schema.oneOf[key], obj[`example-${i}`]);
396
+ i++;
397
+ }
396
398
  }
397
399
  }
398
400
  }
@@ -436,10 +438,10 @@ export function schemaToSampleObj(schema, config = { }) {
436
438
  obj['example-0'] = schema.example;
437
439
  } else {
438
440
  for (const propertyName in schema.properties) {
439
- if (schema.properties[propertyName].deprecated && !config.includeDeprecated) { continue; }
440
- if (schema.properties[propertyName].readOnly && !config.includeReadOnly) { continue; }
441
- if (schema.properties[propertyName].writeOnly && !config.includeWriteOnly) { continue; }
442
- if (schema.properties[propertyName].type === 'array' || schema.properties[propertyName].items) {
441
+ if (schema.properties[propertyName]?.deprecated && !config.includeDeprecated) { continue; }
442
+ if (schema.properties[propertyName]?.readOnly && !config.includeReadOnly) { continue; }
443
+ if (schema.properties[propertyName]?.writeOnly && !config.includeWriteOnly) { continue; }
444
+ if (schema.properties[propertyName]?.type === 'array' || schema.properties[propertyName]?.items) {
443
445
  if (schema.properties[propertyName].example) {
444
446
  addPropertyExampleToObjectExamples(schema.properties[propertyName].example, obj, propertyName);
445
447
  } else if (schema.properties[propertyName]?.items?.example) { // schemas and properties support single example but not multiple examples.
@@ -622,6 +624,7 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
622
624
  obj['::description'] = schema.description || '';
623
625
  obj['::type'] = 'object';
624
626
  obj['::deprecated'] = schema.deprecated || false;
627
+ obj['::readwrite'] = schema.readOnly ? 'readonly' : schema.writeOnly ? 'writeonly' : '';
625
628
  for (const key in schema.properties) {
626
629
  if (schema.required && schema.required.includes(key)) {
627
630
  obj[`${key}*`] = schemaInObjectNotation(schema.properties[key], {}, (level + 1));
@@ -639,6 +642,8 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
639
642
  ? `array<${schema.items.description}>`
640
643
  : '';
641
644
  obj['::type'] = 'array';
645
+ obj['::deprecated'] = schema.deprecated || false;
646
+ obj['::readwrite'] = schema.readOnly ? 'readonly' : schema.writeOnly ? 'writeonly' : '';
642
647
  if (schema.items.items) {
643
648
  obj['::array-type'] = schema.items.items.type;
644
649
  }
@@ -654,7 +659,7 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
654
659
  }
655
660
 
656
661
  /* Create Example object */
657
- export function generateExample(examples = '', example = '', schema, mimeType, includeReadOnly = true, includeWriteOnly = true, outputType = 'json', includeGeneratedExample = false) {
662
+ export function generateExample(schema, mimeType, examples = '', example = '', includeReadOnly = true, includeWriteOnly = true, outputType = 'json', includeGeneratedExample = false) {
658
663
  const finalExamples = [];
659
664
  // First check if examples is provided
660
665
  if (examples) {
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-use-before-define */
2
2
  import OpenApiParser from '@apitools/openapi-parser';
3
- import marked from 'marked';
3
+ import { marked } from 'marked';
4
4
  import { invalidCharsRegEx, rapidocApiKey, sleep } from '~/utils/common-utils';
5
5
 
6
6
  export default async function ProcessSpec(specUrl, generateMissingTags = false, sortTags = false, sortEndpointsBy = '', attrApiKey = '', attrApiKeyLocation = '', attrApiKeyValue = '', serverUrl = '') {
@@ -50,7 +50,7 @@ export default async function ProcessSpec(specUrl, generateMissingTags = false,
50
50
  // const pathGroups = groupByPaths(jsonParsedSpec);
51
51
 
52
52
  // Tags with Paths and WebHooks
53
- const tags = groupByTags(jsonParsedSpec, generateMissingTags, sortTags, sortEndpointsBy);
53
+ const tags = groupByTags(jsonParsedSpec, sortEndpointsBy, generateMissingTags, sortTags);
54
54
 
55
55
  // Components
56
56
  const components = getComponents(jsonParsedSpec);
@@ -239,7 +239,7 @@ function getComponents(openApiSpec) {
239
239
  return components || [];
240
240
  }
241
241
 
242
- function groupByTags(openApiSpec, generateMissingTags = false, sortTags = false, sortEndpointsBy) {
242
+ function groupByTags(openApiSpec, sortEndpointsBy, generateMissingTags = false, sortTags = false) {
243
243
  const supportedMethods = ['get', 'put', 'post', 'delete', 'patch', 'head', 'options']; // this is also used for ordering endpoints by methods
244
244
  const tags = openApiSpec.tags && Array.isArray(openApiSpec.tags)
245
245
  ? openApiSpec.tags.map((v) => ({
package/webpack.config.js CHANGED
@@ -144,6 +144,7 @@ module.exports = {
144
144
  resolve: {
145
145
  fallback: {
146
146
  fs: false,
147
+ buffer: require.resolve('buffer'),
147
148
  },
148
149
  alias: {
149
150
  '~': path.resolve(__dirname, 'src'),
@@ -1,12 +0,0 @@
1
- {
2
- "description": "Tenant Details",
3
- "type": "object",
4
- "properties": {
5
- "empId" : { "type": "string", "description": "Employee ID" },
6
- "firstName" : { "type": "string", "description": "First name" },
7
- "lastName" : { "type": "string", "description": "Last Name" },
8
- "jobTitle" : { "type": "string", "description": "Job title" },
9
- "department": { "type": "string", "description": "Department name"},
10
- "salary" : { "type": "number", "description": "Salary per annum"}
11
- }
12
- }