How to Convert HAL JSON to OpenAPI JSON for JavaScript Client API Generation

493 views Asked by At

We have a Spring Data Rest project producing HAL JSON. We would like to automatically produce a JavaScript Client API based on the HAL JSON. We can very simply convert OpenAPI JSON to a JS Client API using OpenAPITools/openapi-generator, but we have been unable to find a similar tool for HAL JSON. As a workaround, we are exploring converting HAL JSON to OpenAPI JSON in order to leverage the OpenAPITools/openapi-generator project.

Does a HAL JSON to OpenAPI JSON converter exist?

Is there a HAL JSON to JavaScript Client API generator?

Is there a way to skip the HAL JSON step and produce OpenAPI JSON from Spring Data Repository classes?

1

There are 1 answers

0
brianbro On BEST ANSWER

To enable the support of spring-data-rest types: @RepositoryRestResource and QuerydslPredicate annotations, you should use:

<dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-data-rest</artifactId>
      <version>1.4.8</version>
</dependency> 

And you have demos available here: