Browsing your HTTP endpoints
The endpoints component allows you to see all your HTTP endpoints, and also invoke these, similarly to how Swagger works. From your endpoints menu item you can search for, parametrise, and invoke your endpoints, allowing you to simulate a client, and play with your endpoints to understand how they work. Below is a screenshot of how the endpoints component typically looks like.
Notice, endpoints have a type declaration providing some sort of semantic type of information about your endpoint, and typically if this type declaration is “internal”, the endpoint is not intended for being consumed by your own code, but only for internal usage by Magic. If you invoke one of your endpoints you can also create an assumption about your invocation, which becomes the equivalent of an integration tests that’s possible to “replay” later, sanity checking some parts of your system, to verify your system is functioning properly. Below is a screenshot of parametrising an endpoint invocation by adding arguments to it as you invoke it.
Magic will automatically determine what type your query parameter is, and show the correct form control for whatever type is required as input to your endpoint. This implies it will show checbox elements for boolean arguments, date time pickers for date and time arguments, etc. This component also support providing JSON payloads to POST and PUT endpoints, using syntax highlighting through CodeMirror. Below is a screenshot.
When you have invoked an endpoint, Magic allows you to persist your invocation, its response, and automatically “replay” your invocation later, resulting in an “assumption”. Assumptions are high level automated tests, that allows you to sanity check your system, providing similar mechanisms to what unit testing provides you with, only at a much higher abstraction level, since an assumption implies invoking an HTTP endpoint and verifying its response. Below is a screenshot of the process of creating an assumption after you have invoked your endpoint.
As you are browsing your endpoints, and expand individual items, you’ll notice that each endpoint shows you a whole range of “meta data”. This gives you high level information about your endpoints, such as for instance.
- Relative URL
- HTTP verb
- Type of endpoint
- What type of data the endpoint consumes (JSON, Hyperlambda, form-data, etc)
- What type of result the endpoint produces
- Humanly readable description of your endpoint
- Authorisation requirements for invoking the endpoint, implying roles users must belong to in order to invoke the endpoint
- Etc, etc, etc
This information is retrieved directly from your Hyperlambda files, and is just one of those things you get “for free” out of your Magic box. Magic automatically allows you to invoke your user defined endpoints with this component, also directly from Hyper IDE. Below is a screenshot of the latter. Notice, click the “Invoke” button from Hyper IDE to immediately test your endpoint as you create it.