Skip to content

Latest commit

 

History

History
92 lines (71 loc) · 2.8 KB

development.md

File metadata and controls

92 lines (71 loc) · 2.8 KB

Development Guide

Installing dependencies

This app have npm and Bower dependencies. To install all dependencies in one line, run

npm i; bower i

Running

Simply run

grunt serve

if you don't have grunt installed, you can run npm run develop instead.

For development it's preferred to have grunt installed globally on your machine.

Building

To build the project just run:

$ grunt build

This will build a new version of the web app, ready for production in /dist folder

Configuration

Default settings file

Swagger Editor will make an XHR GET call to /config/defaults.json to get it's settings before launching the app. If you are using Swagger Editor as a dependency, you can provide your own defaults.json at this endpoint to override default settings. See ./config.rst and defaults.guide.js

CORS

If you want to import YAML or JSON resources from other hosts, those resources should be served as CORS-enabled resources.

For example, if you get an error such as

{"data":"","status":0,"config":{"method":"GET","transformRequest":[null],"transformResponse":
[null],"url":"http://www.example.com/swagger/apis/swagger.json","headers":{"accept":
"application/x-yaml,text/yaml,application/json,*/*"}}}

this indicates the resource is not CORS-enabled. See ./cors.rst for how to enable CORS.

Running with Docker

If you are familiar with Docker, a Dockerfile is provided.

Build an image named swagger-editor

sudo docker build -t swagger-editor .

Run the container, using the local port 8080 (you may change this to any available port).

sudo docker run -ti -p 8080:8080 swagger-editor

And open http://localhost:8080 in your browser

Code Style

Code style is enforced by JSCS (JavaScript Code Style) and JSHint. Build will fail if changes in code is not following code style guildlines.

Testing

To run all tests run

npm test

This will build and run unit tests then if it was successful, it will run end-to-end tests.

Unit tests

All unit tests are located in ../test/unit. Unit tests are written in Jasmine and run by Karma. To run unit tests, run

grunt karma:unit

For developing unit tests, run

grunt test-dev

This will keep test browser and test watcher open and watches for file changes to re-run tests.

End-to-end tests

All end-to-end tests are located in ../test/e2e. To run end-to-end test, run

grunt protr

This will run Protractor end-to-end test.