We publish two modules to npm: swagger-client.
swagger-client is meant for consumption by any JavaScript engine (node.js, web, etc...).
The npm package contains transpiled and minified ES5 compatible code.
$ npm install swagger-clientAfter installed successfully:
import SwaggerClient from 'swagger-client'const SwaggerClient = require('swagger-client')You can embed Swagger UI's code directly in your HTML by using unpkg's interface.
<html>
<head>
<script src="//unpkg.com/swagger-client"></script>
<script>
new SwaggerClient('http://petstore.swagger.io/v2/swagger.json')
.then(
client => client.apis.pet.addPet({ id: 1, body: { name: "bobby" } }),
reason => console.error('failed to load the spec: ' + reason)
)
.then(
addPetResult => console.log(addPetResult.body),
reason => console.error('failed on api call: ' + reason)
);
</script>
</head>
<body>
check console in browser's dev. tools
</body>
</html>See unpkg's main page for more information on how to use unpkg.
Once swagger-ui has successfully generated the /dist and /browser directory,
you can copy files from those directories to your own file system and host from there.