GithubHelp home page GithubHelp logo

toedter / hal-explorer Goto Github PK

View Code? Open in Web Editor NEW
147.0 147.0 13.0 9.92 MB

An API explorer for RESTful Hypermedia APIs using HAL or HAL-FORMS

License: MIT License

TypeScript 54.71% JavaScript 0.83% HTML 43.92% CSS 0.54%

hal-explorer's People

Contributors

davidbiesack avatar dependabot[bot] avatar toedter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hal-explorer's Issues

Handle all json responses not just code 2xx

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.

[Bug] TypeError: this.halFormsProperties is not iterable

Problem description

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.

Scenario

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

Expected behavior

It should ignore properties if there is none defined, regardless of method.

Configuring an custom Accept header should override defaults

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.

public setCustomHeaders(requestHeaders: RequestHeader[]) {
this.customRequestHeaders = requestHeaders;
this.requestHeaders = new HttpHeaders(
{
'Accept': 'application/hal+json, application/json, */*'
});
for (const requestHeader of requestHeaders) {
this.requestHeaders = this.requestHeaders.append(requestHeader.key, requestHeader.value);
}
}

Relation named "curies [0] in "Links" section

When running backends having curis, e.g. https://github.com/odrotbohm/spring-restbucks, there is a relation named "curies [0] in the "Links" section.

hal-explorer-curis-issue

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
      }
    ]
  }
}

HAL-Forms not using prompt from _templates property

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.

Add support for property regex

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).

Parameters with Templated values not working

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

<base> disallows deployment into a web server context

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

Support for request content types other than json

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.

Please make path adjustable

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

Add option to execute OPTIONS request for a link

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 is always expected as json

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.

OAuth2/login support

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

minimum supported spring boot version

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

Double requests when navigating APIs with HAL explorer

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.

image

Thanks & best wishes
Patrick

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.