All Projects → Orange-OpenSource → Angular Swagger Ui

Orange-OpenSource / Angular Swagger Ui

Licence: other
An angularJS implementation of Swagger UI

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Angular Swagger Ui

Openapi Viewer
Browse and test a REST API described with the OpenAPI 3.0 Specification
Stars: ✭ 82 (-37.4%)
Mutual labels:  api, swagger, openapi, openapi3, swagger-ui, api-documentation
Fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Stars: ✭ 39,588 (+30119.85%)
Mutual labels:  api, swagger, openapi, openapi3, swagger-ui
Flasgger
Easy OpenAPI specs and Swagger UI for your Flask API
Stars: ✭ 2,825 (+2056.49%)
Mutual labels:  api, swagger, openapi, swagger-ui, api-documentation
Springdoc Openapi
Library for OpenAPI 3 with spring-boot
Stars: ✭ 1,113 (+749.62%)
Mutual labels:  swagger, openapi, openapi3, swagger-ui
Vue Openapi
OpenAPI viewer component for VueJS
Stars: ✭ 66 (-49.62%)
Mutual labels:  api, swagger, openapi, openapi3
Openapi.tools
A collection of Editors, Linters, Parsers, Code Generators, Documentation, Testing
Stars: ✭ 257 (+96.18%)
Mutual labels:  swagger, openapi, openapi3, swagger2
Openapi Codegen
OpenAPI 3.0 CodeGen plus Node.js minus the Java and emojis
Stars: ✭ 224 (+70.99%)
Mutual labels:  api, swagger, openapi, openapi3
Awesome Openapi3
😎 A list of awesome projects related to OpenAPI 3.0.x, curated by the community
Stars: ✭ 469 (+258.02%)
Mutual labels:  api, swagger, openapi, openapi3
Dredd
Language-agnostic HTTP API Testing Tool
Stars: ✭ 3,770 (+2777.86%)
Mutual labels:  api, swagger, openapi, openapi3
L5 Swagger
OpenApi or Swagger integration to Laravel
Stars: ✭ 1,781 (+1259.54%)
Mutual labels:  api, swagger, openapi, swagger-ui
Kin Openapi
OpenAPI 3.0 implementation for Go (parsing, converting, validation, and more)
Stars: ✭ 776 (+492.37%)
Mutual labels:  api, swagger, openapi, openapi3
openapi-viewer
Browse and test a REST API described with the OpenAPI 3.0 Specification
Stars: ✭ 85 (-35.11%)
Mutual labels:  api-documentation, openapi, swagger-ui, openapi3
Mockoon
Mockoon is the easiest and quickest way to run mock APIs locally. No remote deployment, no account required, open source.
Stars: ✭ 3,448 (+2532.06%)
Mutual labels:  api, swagger, openapi, openapi3
Oas Kit
Convert Swagger 2.0 definitions to OpenAPI 3.0 and resolve/validate/lint
Stars: ✭ 516 (+293.89%)
Mutual labels:  api, swagger, openapi, openapi3
Apispec
A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)..
Stars: ✭ 831 (+534.35%)
Mutual labels:  api, swagger, openapi, openapi3
Swagger Ui
Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
Stars: ✭ 21,279 (+16143.51%)
Mutual labels:  swagger, openapi, openapi3, swagger-ui
Openapi Diff
Utility for comparing two OpenAPI specifications.
Stars: ✭ 208 (+58.78%)
Mutual labels:  api, swagger, openapi, openapi3
Hexo Theme Doc
A documentation theme for the Hexo blog framework
Stars: ✭ 222 (+69.47%)
Mutual labels:  api, swagger, swagger-ui, api-documentation
Create Openapi Repo
🤖 Generator for GH repo to help you manage the OpenAPI definition lifecycle
Stars: ✭ 513 (+291.6%)
Mutual labels:  swagger, openapi, openapi3, api-documentation
Widdershins
OpenAPI / Swagger, AsyncAPI & Semoasa definitions to (re)Slate compatible markdown
Stars: ✭ 856 (+553.44%)
Mutual labels:  api, swagger, openapi, openapi3

angular-swagger-ui

angular-swagger-ui is an angularJS implementation of OpenAPI UI

OpenAPI (aka Swagger) helps you documenting your RESTful API.

OpenAPI UI helps developers discovering your RESTful API by providing an online documentation with an integrated API explorer.

Warning

By default, only OpenAPI 2.0 is supported. To handle OpenAPI 3.0.0 please add module openapi3-converter see Enable OpenAPI 3.0.0. To handle OpenAPI 1.2 please add module swagger1-converter see Enable OpenAPI 1.2. To handle authorization please add module swagger-auth see Enable authorization To handle YAML please add module swagger-yaml-parser see Enable YAML

Demo

A sample app using angular-swagger-ui is available here:

http://orange-opensource.github.io/angular-swagger-ui

Quick Start

Install

npm install angular-swagger-ui

Dependencies

  1. angularJS
  2. bootstrap CSS
  3. angular-ui-bootstrap (required only if using Authorization)

License

All code in this repository is covered by the MIT license. See LICENSE file for copyright details.

Getting Started

Include angular-swagger-ui as a dependency into your application

As some properties of OpenAPI specifications can be formatted as HTML:

  • You SHOULD include ngSanitize as a dependency into your application (avoids JS injection) if OpenAPI specifications are loaded from untrusted sources (see dist/index.html as an example)
  • You CAN add trusted-sources="true" as directive parameter (avoids embedding ngSanitize) if OpenAPI specifications are loaded from trusted sources (see src/index.html as an example)
  • You MUST at least choose one of the two previous solutions
<script type="text/javascript">
	// If directive has parameter trusted-sources="true"
	angular.module('yourApp', ['swaggerUi']);
	...
	// OR if you choosed to use "ngSanitize"
	angular.module('yourApp', ['ngSanitize', 'swaggerUi']);
	...
</script>

Create an HTML element in your angularJS application's template or in your HTML page

<div swagger-ui url="URLToYourOpenAPISpecification" api-explorer="true"></div>

Add swagger-ui.min.js and angular.min.js at the end of the body

<body>
 	...
 	<script src="yourPathToAngularJS/angular.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/swagger-ui.min.js"></script>
 	<!-- if you choosed to use "ngSanitize" -->
 	<script src="yourPathToAngularSanitize/angular-sanitize.min.js"></script>
</body>

Add swagger-ui.min.css and bootstrap.min.css to the head of the HTML page.

<body>
	<head>
		...
		<link rel="stylesheet" href="yourPathToBootstrapCSS/bootstrap.min.css">
		<link rel="stylesheet" href="yourPathToAngularSwaggerUI/dist/css/swagger-ui.min.css">
  	</head>
</body>

Parameters

API explorer

Display or not API explorer, default is false

<div swagger-ui url="URLToYourOpenAPISpecification" api-explorer="true/false"></div>

OpenAPI specification loading indicator

yourScopeVariable will be assigned to true or false depending on OpenAPI specification loading status

<div ng-show="yourScopeVariable">loading ...</div>
<div swagger-ui url="URLToYourOpenAPISpecification" loading="yourScopeVariable"></div>

Error handler

Define an error handler to catch errors, if none defined console.error is used

<div swagger-ui url="URLToYourOpenAPISpecification" error-handler="yourErrorHandler"></div>
$scope.yourErrorHandler = function(/*String or Object*/ message, /*Integer*/ code){
	
}

Permalinks

Allows having a URL direct access to a group of operations or to an operation and making it unfolded at startup

<div swagger-ui url="URLToYourOpenAPISpecification" permalinks="true/false"></div>

Download

Display or not a link to download swagger file.

<!-- display link with url label -->
<div swagger-ui url="URLToYourOpenAPISpecification" download></div>

<!-- display link with specific key enter in swaggerTranslatorProvider -->
<div swagger-ui url="URLToYourOpenAPISpecification" download="downloadLabel"></div>

OpenAPI validator

Disable OpenAPI validator or define a custom OpenAPI validator. If parameter not defined, the validator will be 'http://online.swagger.io/validator'

<div swagger-ui url="URLToYourOpenAPISpecification" validator-url="false or URL"></div>

Parser type

OpenAPI specification parser is chosen depending on the Content-Type of the specification response. If host serving your OpenAPI specification does not send Content-Type: application/json then you can force the parser to JSON:

<div swagger-ui url="URLToYourOpenAPISpecification" parser="json"></div>

Template URL

Define a custom template to be used by OpenAPIUI

<div swagger-ui url="URLToYourOpenAPISpecification" template-url="yourTemplatePath"></div>

Inherited properties

Allows displaying inherited properties of polymorphic models

<div swagger-ui url="URLToYourOpenAPISpecification" show-inherited-properties="true/false"></div>

Input type and input

Render an OpenAPI specification from JSON object
<div swagger-ui input-type="json" input="yourJsonObject"></div>
Render an OpenAPI specification from YAML string

Make sure to use module swagger-yaml-parser, see Enable YAML

<div swagger-ui input-type="yaml" input="yourYamlString"></div>
Render an OpenAPI specification from URL (same behavior as using "url" parameter)
<div swagger-ui input-type="url" input="yourURL"></div>

i18n

Built-in languages

angular-swagger-ui is available in english and french, english is used by default

To use french, add fr.min.js at the end of the body

<body>
 	...
 	<script src="yourPathToAngularJS/angular.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/swagger-ui.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/i18/fr.min.js"></script>
</body>

Set language to french at startup

<script type="text/javascript">
	angular
		.module('yourApp', ['swaggerUi'])
		.config(function(swaggerTranslatorProvider) {
			swaggerTranslatorProvider.setLanguage('fr');
		});
	...
</script>

Set language to french at runtime

<script type="text/javascript">
	angular
		.module('yourApp', ['swaggerUi'])
		.controller('yourController', function(swaggerTranslator) {
			swaggerTranslator.useLanguage('fr');
		});
	...
</script>

Add languages

You can add your own languages, see src/scripts/i18n/en.js to find the keys you have to override

<script type="text/javascript">
	angular
		.module('yourApp', ['swaggerUi'])
		.config(function(swaggerTranslatorProvider) {
			swaggerTranslatorProvider.addTranslations('yourLangId', {
				key: 'value'
				...
			});
			swaggerTranslatorProvider.setLanguage('yourLangId');
		});
	...
</script>

Internationalize your app

You can also use swaggerTranslator to internationalize your app by using a service, a directive or a filter

<body>
 	...
 	<div swagger-translate="yourKey" swagger-translate-value="yourParam"></div>
 	<div ng-bind="yourDynamicKey|swaggerTranslate:yourDynamicParam"></div>
 	...
	<script type="text/javascript">
		angular
			.module('yourApp', ['swaggerUi'])
			.config(function(swaggerTranslatorProvider) {
				swaggerTranslatorProvider.addTranslations('en', {
					yourKey: 'blablabla {{propertyNameOfYourParam}}'
					...
				});
			})
			.controller('yourController', function(swaggerTranslator) {
				var localizedMessage = swaggerTranslator.translate('yourKey', yourParam);
			});
		...
	</script>
</body>

Customization

Enable OpenAPI 3.0.0

See OpenAPI 3.0.0 spec. Add openapi3-converter.min.js at the end of the body

<body>
 	...
 	<script src="yourPathToAngularJS/angular.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/swagger-ui.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/modules/openapi3-converter.min.js"></script>
</body>

Enable authorization

oauth is not implemented, only basic and API key authorizations are implemented. Add swagger-auth.min.js at the end of the body

<body>
 	...
 	<script src="yourPathToAngularJS/angular.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/swagger-ui.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/modules/swagger-auth.min.js"></script><!-- without angular-ui-bootstrap modal embedded -->
 	OR
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/modules/swagger-auth-ui-boostrap-modal.min.js"></script><!-- angular-ui-bootstrap modal embedded -->
 	...
	<script type="text/javascript">
		angular
			.module('yourApp', ['swaggerUi', 'swaggerUiAuthorization'])
			// what is below is required for oauth2 flows 'implicit' and 'accessCode' (ie. authorizationCode)
			// what is below can also be used to initialize apiKey or Basic authorizations
      .config(function(swaggerUiAuthProvider) {
          swaggerUiAuthProvider.configuration({
              // required for oauth2 flow 'implicit' and 'accessCode' (ie. authorizationCode)
             	redirectUrl: 'yourPathToAngularSwaggerUI/oauth2-redirect.html' 
              // optional
              yourSecurityName: {
              	apiKey: 'yourApiKeyValue' // optional, can be used to initialize api key value
              },
              // optional
              yourSecurityName: {
              	login: 'yourLogin', // optional, can be used to initialize basic login
              	password: 'yourPassword' // optional, can be used to initialize basic password
              },
              // optional
              yourSecurityName: {
              	clientId: 'yourClientId', // optional, can be used to initialize oauth2 credentials
              	clientSecret: 'yourClientSecret', // optional, can be used to initialize oauth2 credentials
              	login: 'yourLogin', // optional, can be used to initialize oauth2 credentials
              	password: 'yourPassword', // optional, can be used to initialize oauth2 credentials
              	scopeSeparator: 'scopeSeparator', // optional, can be used to configure oauth2 scopes separator, default value is space
              	// optional, can be used to configure oauth2 additional query params to tokenUrl and authorizationUrl
              	queryParams: {
              		'yourQueryParamName': 'yourQueryParamValue'
              		...
              	}, 
              },
          });
      })
			...
	</script>
</body>

Enable OpenAPI [aka Swagger] 1.2

See OpenAPI 1.2 spec. Add swagger1-converter.min.js at the end of the body

<body>
 	...
 	<script src="yourPathToAngularJS/angular.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/swagger-ui.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/modules/swagger1-converter.min.js"></script>
</body>

Enable OpenAPI external references

See OpenAPI 2.0 spec. Add swagger-external-references.min.js at the end of the body

<body>
 	...
 	<script src="yourPathToAngularJS/angular.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/swagger-ui.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/modules/swagger-external-references.min.js"></script>
</body>

Enable XML formatter on API explorer responses

Add swagger-xml-formatter.min.js at the end of the body

<body>
 	...
 	<script src="yourPathToAngularJS/angular.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/swagger-ui.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/modules/swagger-xml-formatter.min.js"></script>
</body>

Enable YAML

Add js-yaml library. Add swagger-yaml-parser.min.js at the end of the body

<body>
 	...
 	<script src="yourPathToAngularJS/angular.min.js"></script>
 	<script src="yourPathToJsYaml/js-yaml.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/swagger-ui.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/modules/swagger-yaml-parser.min.js"></script>
</body>

Enable markdown

Add marked library. Add swagger-markdown.min.js at the end of the body

<body>
 	...
 	<script src="yourPathToAngularJS/angular.min.js"></script>
 	<script src="yourPathToMarked/marked.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/swagger-ui.min.js"></script>
 	<script src="yourPathToAngularSwaggerUI/dist/scripts/modules/swagger-markdown.min.js"></script>
</body>

Writing your own modules

Modifying angular-swagger-ui can be achieved by writing your own modules. As an example your can have a look at the ones in src/scripts/modules. A module is an object (can be a service) having a function execute which must return a promise.

You can make your module modifying behaviours at different phases:

  • BEFORE_LOAD: allows modifying OpenAPI specification request before it is sent
  • BEFORE_PARSE: allows modifying OpenAPI specification after it has been loaded
  • PARSE: allows adding an OpenAPI parser for content types other than JSON
  • BEFORE_DISPLAY: allows modifying internal parsed OpenAPI specification before it is displayed
  • BEFORE_EXPLORER_LOAD: allows modifying API explorer request before it is sent
  • AFTER_EXPLORER_LOAD: allows modifying API explorer response before it is displayed
angular
	.module('myApp', ['swaggerUi'])
	.service('myModule', function($q) {

		this.execute = function(data) {
			var deferred = $q.defer();
			// if nothing done: call deferred.resolve(false);
			// if success: call deferred.resolve(true);
			// if error: call deferred.reject({message: 'error message', code: 'error_code'});
			return deferred.promise;
		}

	})
	.run(function(swaggerModules, myModule){
		// default priority is 1
		// higher is the priority, sooner the module is executed at the specified phase
		swaggerModules.add(swaggerModules.BEFORE_LOAD, myModule, priority);
	})
	...

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].