swagger-editor 5.0.0-alpha.74 → 5.0.0-alpha.76

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 (58) hide show
  1. package/README.md +239 -21
  2. package/dist/esm/editor.worker.js +1 -1
  3. package/dist/esm/plugins/dialogs/index.js +2 -0
  4. package/dist/esm/plugins/dialogs/index.js.map +1 -0
  5. package/dist/esm/plugins/dropdown-menu/index.js +2 -0
  6. package/dist/esm/plugins/dropdown-menu/index.js.map +1 -0
  7. package/dist/esm/plugins/dropzone/index.js +2 -0
  8. package/dist/esm/plugins/dropzone/index.js.map +1 -0
  9. package/dist/esm/plugins/editor-content-fixtures/index.js +2 -0
  10. package/dist/esm/plugins/editor-content-fixtures/index.js.map +1 -0
  11. package/dist/esm/plugins/editor-content-origin/index.js +2 -0
  12. package/dist/esm/plugins/editor-content-origin/index.js.map +1 -0
  13. package/dist/esm/plugins/editor-content-persistence/index.js +2 -0
  14. package/dist/esm/plugins/editor-content-persistence/index.js.map +1 -0
  15. package/dist/esm/plugins/editor-content-read-only/index.js +2 -0
  16. package/dist/esm/plugins/editor-content-read-only/index.js.map +1 -0
  17. package/dist/esm/plugins/editor-content-type/index.js +2 -0
  18. package/dist/esm/plugins/editor-content-type/index.js.map +1 -0
  19. package/dist/esm/plugins/editor-monaco/index.js +2 -0
  20. package/dist/esm/plugins/editor-monaco/index.js.map +1 -0
  21. package/dist/esm/plugins/editor-monaco-language-apidom/index.js +2 -0
  22. package/dist/esm/plugins/editor-monaco-language-apidom/index.js.map +1 -0
  23. package/dist/esm/plugins/editor-preview/index.js +2 -0
  24. package/dist/esm/plugins/editor-preview/index.js.map +1 -0
  25. package/dist/esm/plugins/editor-preview-api-design-systems/index.js +2 -0
  26. package/dist/esm/plugins/editor-preview-api-design-systems/index.js.map +1 -0
  27. package/dist/esm/plugins/editor-preview-asyncapi/index.js +2 -0
  28. package/dist/esm/plugins/editor-preview-asyncapi/index.js.map +1 -0
  29. package/dist/esm/plugins/editor-preview-swagger-ui/index.js +2 -0
  30. package/dist/esm/plugins/editor-preview-swagger-ui/index.js.map +1 -0
  31. package/dist/esm/plugins/editor-safe-render/index.js +2 -0
  32. package/dist/esm/plugins/editor-safe-render/index.js.map +1 -0
  33. package/dist/esm/plugins/editor-textarea/index.js +2 -0
  34. package/dist/esm/plugins/editor-textarea/index.js.map +1 -0
  35. package/dist/esm/plugins/layout/index.js +2 -0
  36. package/dist/esm/plugins/layout/index.js.map +1 -0
  37. package/dist/esm/plugins/modals/index.js +2 -0
  38. package/dist/esm/plugins/modals/index.js.map +1 -0
  39. package/dist/esm/plugins/splash-screen/index.js +2 -0
  40. package/dist/esm/plugins/splash-screen/index.js.map +1 -0
  41. package/dist/esm/plugins/swagger-ui-adapter/index.js +2 -0
  42. package/dist/esm/plugins/swagger-ui-adapter/index.js.map +1 -0
  43. package/dist/esm/plugins/top-bar/index.js +2 -0
  44. package/dist/esm/plugins/top-bar/index.js.map +1 -0
  45. package/dist/esm/plugins/versions/index.js +2 -0
  46. package/dist/esm/plugins/versions/index.js.map +1 -0
  47. package/dist/esm/presets/monaco/index.js +2 -0
  48. package/dist/esm/presets/monaco/index.js.map +1 -0
  49. package/dist/esm/presets/textarea/index.js +2 -0
  50. package/dist/esm/presets/textarea/index.js.map +1 -0
  51. package/dist/esm/swagger-editor.js +1 -1
  52. package/dist/esm/swagger-editor.js.map +1 -1
  53. package/dist/swagger-editor.css +1 -5
  54. package/dist/umd/apidom.worker.js +1 -1
  55. package/dist/umd/editor.worker.js +1 -1
  56. package/dist/umd/swagger-editor.js +1 -1
  57. package/package.json +9 -3
  58. package/dist/umd/e3a78774c6913562ff73.html +0 -123
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SwaggerEditor
2
2
 
3
- SwaggerEditor is using **forked** Create React App as it's building infrastructure.
3
+ SwaggerEditor is using [**forked** Create React App](https://github.com/swagger-api/swagger-editor-cra/) as it's building infrastructure.
4
4
 
5
5
  ## Table of Contents
6
6
 
@@ -451,10 +451,16 @@ SwaggerEditor maps its [build artifacts](#build-artifacts) in `package.json` fil
451
451
  "jsnext:main": "./dist/esm/swagger-editor.js",
452
452
  "exports": {
453
453
  "./package.json": "./package.json",
454
- "./swagger-editor.css": "./dist/esm/swagger-editor.css",
454
+ "./swagger-editor.css": "./dist/swagger-editor.css",
455
455
  ".": {
456
456
  "browser": "./dist/esm/swagger-editor.js"
457
457
  },
458
+ "./plugins/*": {
459
+ "browser": "./dist/esm/plugins/*/index.js"
460
+ },
461
+ "./presets/*": {
462
+ "browser": "./dist/esm/presets/*/index.js"
463
+ },
458
464
  "./apidom.worker": {
459
465
  "browser": "./dist/esm/apidom.worker.js"
460
466
  },
@@ -482,8 +488,8 @@ Environment variables currently available:
482
488
 
483
489
  | Variable name | Description |
484
490
  |-----------------------------|:----------------------------------------------------------------------------------------------------------:|
485
- | `REACT_APP_DEFINITION_FILE` | Specifies a local file path, and the specified file must also be present in the `/public/static` directory |
486
- | `REACT_APP_DEFINITION_URL` | Specifies a remote URL. This environment variable currently takes precedence over `REACT_APP_SWAGGER_FILE` |
491
+ | `REACT_APP_DEFINITION_FILE` | Specifies a local file path, and the specified file must also be present in the `/public/static` directory |
492
+ | `REACT_APP_DEFINITION_URL` | Specifies a remote URL. This environment variable currently takes precedence over `REACT_APP_SWAGGER_FILE` |
487
493
  | `REACT_APP_VERSION` | Specifies the version of this app. The version is read from `package.json` file. |
488
494
 
489
495
  Sample environment variable values can be found in `.env` file. For more information about using
@@ -501,31 +507,243 @@ the definition that's being created in the editor. These plugins include:
501
507
  With a bit of adapting, we can use these plugins with SwaggerUI to provide ability
502
508
  to render AsyncAPI or API Design Systems definitions with SwaggerUI.
503
509
 
510
+ ```js
511
+ import SwaggerUI from 'swagger-ui';
512
+ import SwaggerUIStandalonePreset from 'swagger-ui/dist/swagger-ui-standalone-preset';
513
+ import 'swagger-ui/dist/swagger-ui.css';
514
+ import EditorContentTypePlugin from 'swagger-editor/plugins/editor-content-type';
515
+ import EditorPreviewAsyncAPIPlugin from 'swagger-editor/plugins/editor-preview-asyncapi';
516
+ import EditorPreviewAPIDesignSystemsPlugin from 'swagger-editor/plugins/editor-preview-api-design-systems';
517
+ import SwaggerUIAdapterPlugin from 'swagger-editor/plugins/swagger-ui-adapter';
518
+
519
+ SwaggerUI({
520
+ url: 'https://petstore.swagger.io/v2/swagger.json',
521
+ dom_id: '#swagger-ui',
522
+ presets: [SwaggerUI.presets.apis, SwaggerUIStandalonePreset],
523
+ plugins: [
524
+ EditorContentTypePlugin,
525
+ EditorPreviewAsyncAPIPlugin,
526
+ EditorPreviewAPIDesignSystemsPlugin,
527
+ SwaggerUIAdapterPlugin,
528
+ SwaggerUI.plugins.DownloadUrl,
529
+ ],
530
+ });
531
+ ```
532
+
533
+ The key here is `SwaggerUIAdapter` plugin which adapts SwaggerEditor plugins to use
534
+ directly with SwaggerUI.
535
+
536
+ #### Standalone mode
537
+
538
+ SwaggerUI standalone mode is supported as well. With standalone mode you'll get a `TopBar` with
539
+ an input where URL of the definition can be provided and this definition is subsequently loaded
540
+ by the SwaggerUI.
541
+
542
+ ```js
543
+ import SwaggerUI from 'swagger-ui';
544
+ import SwaggerUIStandalonePreset from 'swagger-ui/dist/swagger-ui-standalone-preset';
545
+ import 'swagger-ui/dist/swagger-ui.css';
546
+ import EditorContentTypePlugin from 'swagger-editor/plugins/editor-content-type';
547
+ import EditorPreviewAsyncAPIPlugin from 'swagger-editor/plugins/editor-preview-asyncapi';
548
+ import EditorPreviewAPIDesignSystemsPlugin from 'swagger-editor/plugins/editor-preview-api-design-systems';
549
+ import SwaggerUIAdapterPlugin from 'swagger-editor/plugins/swagger-ui-adapter';
550
+
551
+ SwaggerUI({
552
+ url: 'https://petstore.swagger.io/v2/swagger.json',
553
+ dom_id: '#swagger-ui',
554
+ presets: [SwaggerUI.presets.apis, SwaggerUIStandalonePreset],
555
+ plugins: [
556
+ EditorContentTypePlugin,
557
+ EditorPreviewAsyncAPIPlugin,
558
+ EditorPreviewAPIDesignSystemsPlugin,
559
+ SwaggerUIAdapterPlugin,
560
+ SwaggerUI.plugins.DownloadUrl,
561
+ ],
562
+ layout: 'StandaloneLayout',
563
+ });
564
+ ```
565
+
566
+ ### Composing customized SwaggerEditor version
567
+
568
+ SwaggerEditor is just a number of SwaggerUI plugins used with [swagger-ui-react](https://www.npmjs.com/package/swagger-ui-react).
569
+ Customized SwaggerEditor can be created by composing individual plugins with either [swagger-ui](https://www.npmjs.com/package/swagger-ui) and [swagger-ui-react](https://www.npmjs.com/package/swagger-ui-react).
570
+
571
+ #### Plugins
572
+
573
+ List of available plugins:
574
+
575
+ - dialogs
576
+ - dropdown-menu
577
+ - dropzone
578
+ - editor-content-fixtures
579
+ - editor-content-origin
580
+ - editor-content-persistence
581
+ - editor-content-read-only
582
+ - editor-content-type
583
+ - editor-monaco
584
+ - editor-monaco-language-apidom
585
+ - editor-preview
586
+ - editor-preview-api-design-systems
587
+ - editor-preview-asyncapi
588
+ - editor-preview-swagger-ui
589
+ - editor-safe-render
590
+ - editor-textarea
591
+ - layout
592
+ - modals
593
+ - splash-screen
594
+ - swagger-ui-adapter
595
+ - top-bar
596
+ - versions
597
+
598
+ Individual plugins can be imported in the following way:
599
+
600
+ ```js
601
+ import EditorContentTypePlugin from 'swagger-editor/plugins/editor-content-type';
602
+ import EditorContentReadOnlyPlugin from 'swagger-editor/plugins/editor-content-read-only';
603
+ ```
604
+
605
+ #### Presets
606
+
607
+ Along with plugins, presets are available as well. Preset is a collection of plugins
608
+ that are design to work together to provide a compound feature.
609
+
610
+ List of available presets:
611
+
612
+ - textarea
613
+ - monaco
614
+
615
+ Individual presets can be imported in the following way:
616
+
617
+ ```js
618
+ import TextareaPreset from 'swagger-editor/presets/textarea';
619
+ import MonacoPreset from 'swagger-editor/presets/monaco';
620
+ ```
621
+
622
+ > NOTE: Please refer to the [Plug points documentation](https://github.com/swagger-api/swagger-ui/blob/master/docs/customization/plug-points.md)
623
+ of SwaggerUI to understand how presets are passed to SwaggerUI.
624
+
625
+
626
+ #### Composing with swagger-ui
627
+
628
+ ```js
629
+ import SwaggerUI from 'swagger-ui';
630
+ import 'swagger-ui/dist/swagger-ui.css';
631
+ import ModalsPlugin from 'swagger-editor/plugins/modals';
632
+ import DialogsPlugin from 'swagger-editor/plugins/dialogs';
633
+ import DropdownMenuPlugin from 'swagger-editor/plugins/dropdown-menu';
634
+ import DropzonePlugin from 'swagger-editor/plugins/dropzone';
635
+ import VersionsPlugin from 'swagger-editor/plugins/versions';
636
+ import EditorTextareaPlugin from 'swagger-editor/plugins/editor-textarea';
637
+ import EditorMonacoPlugin from 'swagger-editor/plugins/editor-monaco';
638
+ import EditorMonacoLanguageApiDOMPlugin from 'swagger-editor/plugins/editor-monaco-language-apidom';
639
+ import EditorContentReadOnlyPlugin from 'swagger-editor/plugins/editor-content-read-only';
640
+ import EditorContentOriginPlugin from 'swagger-editor/plugins/editor-content-origin';
641
+ import EditorContentTypePlugin from 'swagger-editor/plugins/editor-content-type';
642
+ import EditorContentPersistencePlugin from 'swagger-editor/plugins/editor-content-persistence';
643
+ import EditorContentFixturesPlugin from 'swagger-editor/plugins/editor-content-fixtures';
644
+ import EditorPreviewPlugin from 'swagger-editor/plugins/editor-preview';
645
+ import EditorPreviewSwaggerUIPlugin from 'swagger-editor/plugins/editor-preview-swagger-ui';
646
+ import EditorPreviewAsyncAPIPlugin from 'swagger-editor/plugins/editor-preview-asyncapi';
647
+ import EditorPreviewApiDesignSystemsPlugin from 'swagger-editor/plugins/editor-preview-api-design-systems';
648
+ import TopBarPlugin from 'swagger-editor/plugins/top-bar';
649
+ import SplashScreenPlugin from 'swagger-editor/plugins/splash-screen';
650
+ import LayoutPlugin from 'swagger-editor/plugins/layout';
651
+ import EditorSafeRenderPlugin from 'swagger-editor/plugins/editor-safe-render';
652
+
653
+ SwaggerUI({
654
+ url: 'https://petstore.swagger.io/v2/swagger.json',
655
+ dom_id: '#swagger-editor',
656
+ plugins: [
657
+ ModalsPlugin,
658
+ DialogsPlugin,
659
+ DropdownMenuPlugin,
660
+ DropzonePlugin,
661
+ VersionsPlugin,
662
+ EditorTextareaPlugin,
663
+ EditorMonacoPlugin,
664
+ EditorMonacoLanguageApiDOMPlugin,
665
+ EditorContentReadOnlyPlugin,
666
+ EditorContentOriginPlugin,
667
+ EditorContentTypePlugin,
668
+ EditorContentPersistencePlugin,
669
+ EditorContentFixturesPlugin,
670
+ EditorPreviewPlugin,
671
+ EditorPreviewSwaggerUIPlugin,
672
+ EditorPreviewAsyncAPIPlugin,
673
+ EditorPreviewApiDesignSystemsPlugin,
674
+ TopBarPlugin,
675
+ SplashScreenPlugin,
676
+ LayoutPlugin,
677
+ EditorSafeRenderPlugin,
678
+ ],
679
+ layout: 'StandaloneLayout',
680
+ });
681
+ ```
682
+
683
+ #### Composing with swagger-ui-react
684
+
504
685
  ```js
505
686
  import React from 'react';
506
687
  import ReactDOM from 'react-dom';
507
688
  import SwaggerUI from 'swagger-ui-react';
508
689
  import 'swagger-ui-react/swagger-ui.css';
509
- import SwaggerEditor from 'swagger-editor';
690
+ import ModalsPlugin from 'swagger-editor/plugins/modals';
691
+ import DialogsPlugin from 'swagger-editor/plugins/dialogs';
692
+ import DropdownMenuPlugin from 'swagger-editor/plugins/dropdown-menu';
693
+ import DropzonePlugin from 'swagger-editor/plugins/dropzone';
694
+ import VersionsPlugin from 'swagger-editor/plugins/versions';
695
+ import EditorTextareaPlugin from 'swagger-editor/plugins/editor-textarea';
696
+ import EditorMonacoPlugin from 'swagger-editor/plugins/editor-monaco';
697
+ import EditorMonacoLanguageApiDOMPlugin from 'swagger-editor/plugins/editor-monaco-language-apidom';
698
+ import EditorContentReadOnlyPlugin from 'swagger-editor/plugins/editor-content-read-only';
699
+ import EditorContentOriginPlugin from 'swagger-editor/plugins/editor-content-origin';
700
+ import EditorContentTypePlugin from 'swagger-editor/plugins/editor-content-type';
701
+ import EditorContentPersistencePlugin from 'swagger-editor/plugins/editor-content-persistence';
702
+ import EditorContentFixturesPlugin from 'swagger-editor/plugins/editor-content-fixtures';
703
+ import EditorPreviewPlugin from 'swagger-editor/plugins/editor-preview';
704
+ import EditorPreviewSwaggerUIPlugin from 'swagger-editor/plugins/editor-preview-swagger-ui';
705
+ import EditorPreviewAsyncAPIPlugin from 'swagger-editor/plugins/editor-preview-asyncapi';
706
+ import EditorPreviewApiDesignSystemsPlugin from 'swagger-editor/plugins/editor-preview-api-design-systems';
707
+ import TopBarPlugin from 'swagger-editor/plugins/top-bar';
708
+ import SplashScreenPlugin from 'swagger-editor/plugins/splash-screen';
709
+ import LayoutPlugin from 'swagger-editor/plugins/layout';
710
+ import EditorSafeRenderPlugin from 'swagger-editor/plugins/editor-safe-render';
711
+
712
+ const SwaggerEditor = () => {
713
+ return (
714
+ <SwaggerUI
715
+ url={url}
716
+ plugins={[
717
+ ModalsPlugin,
718
+ DialogsPlugin,
719
+ DropdownMenuPlugin,
720
+ DropzonePlugin,
721
+ VersionsPlugin,
722
+ EditorTextareaPlugin,
723
+ EditorMonacoPlugin,
724
+ EditorMonacoLanguageApiDOMPlugin,
725
+ EditorContentReadOnlyPlugin,
726
+ EditorContentOriginPlugin,
727
+ EditorContentTypePlugin,
728
+ EditorContentPersistencePlugin,
729
+ EditorContentFixturesPlugin,
730
+ EditorPreviewPlugin,
731
+ EditorPreviewSwaggerUIPlugin,
732
+ EditorPreviewAsyncAPIPlugin,
733
+ EditorPreviewApiDesignSystemsPlugin,
734
+ TopBarPlugin,
735
+ SplashScreenPlugin,
736
+ LayoutPlugin,
737
+ EditorSafeRenderPlugin,
738
+ ]}
739
+ layout="StandaloneLayout"
740
+ />
741
+ );
742
+ };
510
743
 
511
- const plugins = [
512
- SwaggerEditor.plugins.EditorContentType,
513
- SwaggerEditor.plugins.EditorPreviewAsyncAPI,
514
- SwaggerEditor.plugins.EditorPreviewAPIDesignSystems,
515
- SwaggerEditor.plugins.SwaggerUIAdapter,
516
- ];
517
-
518
- ReactDOM.render(
519
- <SwaggerUI
520
- plugins={plugins}
521
- url="https://raw.githubusercontent.com/asyncapi/spec/v2.4.0/examples/streetlights-kafka.yml"
522
- />,
523
- document.getElementById('swagger-ui')
524
- );
744
+ ReactDOM.render(<SwaggerEditor />, document.getElementById('swagger-editor'));
525
745
  ```
526
746
 
527
- The key here is `SwaggerUIAdapter` plugin which adapts SwaggerEditor plugins to use
528
- directly with SwaggerUI.
529
747
 
530
748
  ## Docker
531
749