index.js 951 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Requiring virtual module generated in memory by the Webpack Virtual Modules plugin
  2. const swaggerJson = require('swagger.json');
  3. const swaggerUi = require('swagger-ui');
  4. require('swagger-ui/dist/swagger-ui.css');
  5. /**
  6. * @swagger
  7. * /api/hello:
  8. * get:
  9. * description: Returns hello message
  10. * parameters:
  11. * - name: subject
  12. * in: query
  13. * schema:
  14. * type: string
  15. * responses:
  16. * '200':
  17. * content:
  18. * application/json:
  19. * schema:
  20. * type: string
  21. */
  22. function getHello(name) {
  23. // TODO: Replace the code with a REST API call when it's implemented on the backend
  24. return { message: 'Hello ' + name + '!' };
  25. }
  26. var helloDiv = document.getElementById('hello');
  27. helloDiv.innerHTML = getHello('World').message;
  28. swaggerUi({
  29. spec: swaggerJson, dom_id: '#apiDocs',
  30. presets: [
  31. swaggerUi.presets.apis,
  32. swaggerUi.SwaggerUIStandalonePreset
  33. ]
  34. });