toedter / hal-explorer Goto Github PK
View Code? Open in Web Editor NEWAn API explorer for RESTful Hypermedia APIs using HAL or HAL-FORMS
License: MIT License
An API explorer for RESTful Hypermedia APIs using HAL or HAL-FORMS
License: MIT License
At least if the response Content-Type is application/hal+json
or other hal compatible types like application/vnd.error+json
then it would be nice if the response body was handled regardless of the response code. And in general the response body could still be shown for all application/*+json
type responses.
HAL Explorer Version: v1.0.0
HAL Explorer does not correctly handle a potential lack of properties
for HTTP methods that normally take request bodies.
I have a sample template:
{
"_templates": {
"clear": {
"title": "Clear all items",
"method": "POST",
"contentType": "application/json",
"target": "/api/carts/2e769b7c-2fff-4830-9beb-737c3a4a65e9/clear"
}
}
}
When clicking the button in the UI, the request fails in the background:
main-es2015.71f7e9a03e1c3ab8ebcc.js:1 ERROR Error: Uncaught (in promise): TypeError: this.halFormsProperties is not iterable
TypeError: this.halFormsProperties is not iterable
It should ignore properties
if there is none defined, regardless of method.
A HAL-FORMS contentType property is ignored, Explorer always sends application/json. application/x-www-form-urlencoded should be supported too.
When a hal form contains a property with type file it still uses a JSON request body.
The application of custom headers currently adds default Accept
headers no matter what and appends all headers configured. This renders defining a custom Accept header not taking effect, especially as the default contains */*
.
If you define foo/bar
as custom accept header and the server is able to produce both one of the defaults and the custom media type, it would still render the default one as it matches first.
hal-explorer/src/app/request/request.service.ts
Lines 227 to 236 in c84c147
I'd be nice to have OIDC (OpenID Connect) support.
Maybe via https://github.com/manfredsteyer/angular-oauth2-oidc .
I can make a contribution for that if you are interested.
In some situations, mostly when the server is not responsive but HAL-Explorer is still in the browser cache, a JSON like:
{
"isTrusted": true
}
When running backends having curis, e.g. https://github.com/odrotbohm/spring-restbucks, there is a relation named "curies [0] in the "Links" section.
All relations in the "restbucks" curi namespace have a (working) document icon (with working link on it).
Shouldn't be the "curies" relation filtered from the "links" section since it's not a real link relation but one with a special meaning?
Response body is/was
{
"_links": {
"restbucks:orders": {
"href": "http://localhost:8080/orders{?page,size,sort,projection}",
"templated": true,
"title": "Access or create orders"
},
"profile": {
"href": "http://localhost:8080/profile"
},
"curies": [
{
"href": "http://localhost:8080/docs/{rel}.html",
"name": "restbucks",
"templated": true
}
]
}
}
It would be cool if the form created to capture the properties of a HAL Forms template to verify the expression in regex
and prevent the form from being submitted unless they match.
Example:
To test, do a GET request on one of the links.
(this is probably a stretch, but I probably can't convince you to give https://github.com/badgateway/ketting a shot for this project? You might like it and we can combine efforts!)
When runing https://github.com/odrotbohm/spring-restbucks without affordance HAL-Explorer (content-type application/prs.hal-forms+json
) renders the links as followed
but when using affordance (content-type application/hal+json
), "HAL-FORMS Template Elements" are added correctly, but all link in the above "Links"-Section lose all there buttons beside the "GET"-Buttons.
HAL-Explorer: v0.10.0
(I recognize that you just added HAL Forms and it's probably not done yet...)
// ...
"_templates": {
"default": {
"title": null,
"method": "patch",
"contentType": "",
"properties": [ { ... },
{
"name": "lastName",
"prompt": "Last Name",
"regex": "[a-zA-Z]*",
"required": false
}, { ... }, ...
]
// ...
When I open the HTTP Request Input dialog the HAL-Forms Properties labels are all empty.
Use regex (if present) to create/put/patch form elements validation, now that Spring-HATEOAS is supplying it.
I'd be happy to contribute a PR, but I'd need a bit of help orienting myself in the Angular code (I'm a React guy and I've managed to avoid ever having to do any real work in Angular up until now).
hi
i'm using version 0.13.0
i have an issue with the templated links with a backend responding "application/hal+json" media type.
my link is like that:
"compute-all": { "href": "http://localhost:8086/rest/internal/hpa/product-snapshots/_compute_all?application={application}", "templated": true },
and the browser does not parse parameters as it would do with HalFom response, it only put "http://localhost:8086/rest/internal/hpa/product-snapshots/_compute_all?application=" without being able to change it.
i understand that HAL+Json is on the way to be deprecated but i would like the HAL_explorer to be compatible with both kind of api i got
After running
npm run build -prod
I pointed a Tomcat context to the HAL explorer dist
folder
<Context path="/hal-explorer" docBase="/Users/.../path/to/hal-explorer/dist" reloadable="true">
<Resources allowLinking="true" />
</Context>
and opened http://localhost:8080/hal-explorer in my browser, but it failed because of the
<base href="/">
It tries to load http://localhost:8080/scripts.82689310a4d7f41146ed.bundle.js instead of http://localhost:8080/hal-explorer/scripts.82689310a4d7f41146ed.bundle.js
Removing the<base>
element from index.html resolves this, and running locally via npm start
also works on localhost:4200
At the moment only json as request body content type is supported.
If a hal form does not support this content-type the form should be not available in the hal forms section or it should not be submittable in the form dialog (with a hint explaining that only json is supported).
Future goal:
Support FormData (application/x-www-form-urlencoded and multipart/form-data) via https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects.
Currently, the HAL explorer is under the root path, but this will collide with web applications. Please make the path adjustable via a configuration property like
spring.data.rest.hal-explorer-base-path=/api
It would be nice if the explorer had an option where the user can decide if for a single or each link an OPTIONS request should be executed.
The allow response header could be used to enable/disable the request buttons besides the link.
Response types other than json are always handled as error.
For other response types an iframe could be used, hoping the browser can handle it.
Currently, the HAL-FORM request editor validation creates tooltips for the error messages.
While this keeps the form layout stable, it is not the best UX for the user.
Hi,
since Spring Boot 2.2 the "hal-browser" is marked as deprecated and developers are encouraged to switch to "hal-explorer".
Are there any plans to support (any sort of) login mechanism ? Ideally, Oauth2 would be great.
Is this feature already available, but I missed it accidently ?!
Greetings
Hello,
I am trying to integrate into a spring-boot 2.1.6 application.
Nothing happens when I navigate to the root of the server.
Is there a setup step I am missing?
Kind regards,
Amnon
Hi Kai
When working with HAL explorer, I regulary see double requests in my logs and Network tab in DevTools.
Example
Open HAL Explorer Demo (1.1.1) and open e.g. Chrome's Network tab in DevTools.
Trigger the GET request via GET button for relation hal-movies. You'll see two requests. One after another. As far as I can see both are identical - same behaviour in Firefox.
Same when you e.g paste https://toedter.github.io/hal-explorer/release/hal-explorer/examples/movies.hal.json
into the input field and push the Go! button. Two requests visible in Network tab after that. Pushing the Go! button a second time only results in a single request.
My RESTful APIs navigated with HAL explorer regularly show two identical log entries for request. Can you please clarify whether this is intended or a bug.
Thanks & best wishes
Patrick
HAL-Explorer: v0.10.0
Given a URI template:
http://localhost:8081/v1/customer/{customerId}
The template is expanded as:
http://localhost:8081/v1/customer/?customerId=12345
Where I am expecting (and so is Spring-Hateoas):
http://localhost:8081/v1/customer/12345
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.