You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mock.js 1.4 KiB

8 vuotta sitten
8 vuotta sitten
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* jshint ignore:start */
  2. $(function () {
  3. 'use strict';
  4. var url = window.location.search.match(/url=([^&]+)/);
  5. if (url && url.length > 1) {
  6. url = decodeURIComponent(url[1]);
  7. } else {
  8. url = 'http://petstore.swagger.io/v2/swagger.json';
  9. }
  10. // Pre load translate...
  11. if(window.SwaggerTranslator) {
  12. window.SwaggerTranslator.translate();
  13. }
  14. window.swaggerUi = new SwaggerUi({
  15. url: url,
  16. dom_id: 'swagger-ui-container',
  17. supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
  18. onComplete: function(){
  19. if(typeof initOAuth === 'function') {
  20. initOAuth({
  21. clientId: 'your-client-id',
  22. clientSecret: 'your-client-secret-if-required',
  23. realm: 'your-realms',
  24. appName: 'your-app-name',
  25. scopeSeparator: ',',
  26. additionalQueryStringParams: {}
  27. });
  28. }
  29. if(window.SwaggerTranslator) {
  30. window.SwaggerTranslator.translate();
  31. }
  32. $('pre code').each(function(i, e) {
  33. hljs.highlightBlock(e);
  34. });
  35. },
  36. onFailure: function() {
  37. log('Unable to Load SwaggerUI');
  38. },
  39. docExpansion: 'none',
  40. jsonEditor: false,
  41. apisSorter: 'alpha',
  42. defaultModelRendering: 'schema',
  43. showRequestHeaders: false
  44. });
  45. window.swaggerUi.load();
  46. function log() {
  47. if ('console' in window) {
  48. console.log.apply(console, arguments);
  49. }
  50. }
  51. });
  52. /* jshint ignore:end */