External body
extended return support (not specified in the configuration file)
By default, moclojer reads the endpoint.response.body
parameter for the endpoint return, but when we need a “long” return (with lots of characters) the specification file (yaml example) makes it difficult to maintain and leaves it with low visibility (confusing).
To solve this problem you can stop using endpoint.response.body
and use endpoint.response.external-body
which has the following structure:
We support two providers (file type):
json
, with file support (on local disk) or remote via httpxlsx
(excel)
it is possible to use template rendering to declare the
path
of the file, see more here.
json
type
json
typeSwagger:
GET
/external-body-text
Will return the text from the file test/com/moclojer/resources/text-plan.json
.
http request (API proxy)
You can use the json
provider to make URL (site) requests and have it returned to the endpoint:
Swagger:
GET
/pokemon/phanpy
Will return the text from the URL https://pokeapi.co/api/v2/pokemon/phanpy
.
xlsx
Excel type
xlsx
Excel typeThis is where the use of moclojer starts to get different, as it is possible to “transform” an Excel spreadsheet into an API return (json
).
Excel spreadsheet example (excel-sample.xlsx
):
avelino
clojure, go
chicao
clojure, python
Swagger:
GET
/xlsx
Will return the text from the file test/com/moclojer/resources/excel-sample.xlsx
.
Last updated