Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. // swagger.yml
  2.  
  3. ---
  4. swagger: '2.0'
  5. info:
  6. version: 3.0.1
  7. title: The coolest API
  8. paths:
  9. /:
  10. get:
  11. produces:
  12. - text/html
  13. responses:
  14. 200:
  15. description: Return index page
  16. schema:
  17. type: string
  18.  
  19. // go file
  20.  
  21. swaggerSpec, err := loads.Analyzed(restapi.SwaggerJSON, "")
  22. ...
  23. api := operations.NewYOURAPI(swaggerSpec)
  24. api.HTMLProducer = runtime.TextProducer()
  25. ...
  26.  
  27. api.GetHandler = operations.GetHandlerFunc(
  28. func(params operations.GetParams) middleware.Responder {
  29. return operations.NewGetOK().WithPayload("<!DOCTYPE html><html> <body> <h1>My First Heading</h1> <p>My first paragraph.</p> </body> </html>")
  30. })
  31.  
  32. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement