Prettier Code Formatter Configuration

Goals Setup Prettier for different environments / IDEs Run Prettier via git hooks Install Prettier Install via npm npm install --save-dev --save-exact prettier Add empty configuration file echo {}> .prettierrc.json Create Prettier ignore file .prettierignore: # Ignore artifacts: build coverage Format all project files with Prettier: npx prettier --write . Git Hooks Adding the following lines to the project’s package-json makes ESLint and Prettier run before each commit: { "husky": { "hooks": { "pre-commit": "lint-staged" } }, "lint-staged": { "**/*": "prettier --write --ignore-unknown" } } ...

May 14, 2021 · 1 min · 90 words · Micha Kops

Testing OpenAPI Swagger Schema Compliance with Java, JUnit and assertj-swagger

The OpenAPI and Swagger API description format are becoming important standards to specify API contracts for RESTful web services and the Microservices trend pushes the need for such contracts even further. Therefore arises the need for software architects, testers and developers to write tests to verify if an exposed API follows such a specified contract. In the following tutorial I will demonstrate a setup with Java, Maven, JUnit and the designated contract-testing-library, assertj-swagger that verifies the validity of such a contract exposed by a Spring Boot application against a local stored definition. ...

August 31, 2018 · 5 min · 871 words · Micha Kops

Writing BDD-Style Webservice Tests with Karate and Java

There is a new testing framework out there called Karate that is build on top of the popular Cucumber framework. Karate makes it easy to script interactions with out web-services under test and verify the results. In addition it offers us a lot of useful features like parallelization, script/feature re-use, data-tables, JsonPath and XPath support, gherkin syntax, switchable staging-configurations and many others. In the following tutorial we’ll be writing different scenarios and features for a real-world RESTful web-service to demonstrate some of its features. ...

April 6, 2017 · 12 min · 2549 words · Micha Kops

Transforming JSON Structures with Java and JOLT

When it comes to web-services (especially RESTful web-services), configuration files or other data-descriptors, the JavaScript Object Notation, short: JSON is often used as format of choice. As the task arises to transform these JSON structures, I have seen a variety of different approaches from converting JSON into XML using JAX-B, applying XSLT, transforming into JSON again on the one hand to loading JSON structures into Hash-maps of Hash-maps (..) and manually removing single elements from these collections on the other hand. ...

January 29, 2017 · 8 min · 1520 words · Micha Kops

Creating REST Clients for JAX-RS based Webservices with Netflix Feign

For us developers there plenty of libraries exist helping us in deriving and generating clients for existing RESTful web-services and I have already covered some of the in this blog (e.g. the JAX-RS Client API). Nevertheless, I’d like to share my experience with another interesting lightweight library here: Netflix Feign. Feign offers a nice fluent-builder API, a rich integration for common libraries and APIs like JAX-RS, Jackson, GSON, SAX, JAX-B, OkHttp, Ribbon, Hystrix, SLF4J and more and last bot not least, it is setup easy and the service contracts are specified using interfaces and annotations. ...

October 22, 2015 · 6 min · 1138 words · Micha Kops

Integrating Swagger into a Spring Boot RESTful Webservice with Springfox

Spring Boot allows us to create RESTful web-services with ease, Swagger specifies a format to describe the capabilities and operations of these services and with Swagger UI it is possible to explore our REST API with a nice graphical user interface in our browser. Springfox is a project that aims at creating automated JSON API documentation for API’s built with Spring and is used in the following tutorial to integrate Swagger into a sample application. ...

July 1, 2015 · 7 min · 1418 words · Micha Kops

Documenting RESTful Webservices in Swagger, AsciiDoc and Plain Text with Maven and the JAX-RS Analyzer

A variety of different tools exists to help us analyze RESTful web-services and create documentations for their APIs in different formats. In the following tutorial I’d like to demonstrate how to document an existing JAX-RS web-service in multiple formats like Swagger, AsciiDoc or Plain Text using Maven, the JAX-RS Analyzer and the JAX-RS Analyzer Maven Plugin. The JAX-RS Analyzer gathers its information not only by reflection like most other tools but also by bytecode analysis and therefore does not require us to add special annotations for documentation to our code. ...

June 16, 2015 · 6 min · 1119 words · Micha Kops

Creating a hybrid mobile Application with Ionic, Cordova and AngularJS

Nowadays in the realm of hybrid mobile application development there is a variety of available frameworks worth having a look at. In the following tutorial I’d like to demonstrate the development life-cycle for a complete mobile application using Ionic, Cordova and AngularJS (and others) covering every step from the initial project setup, creating Angular Controllers, Directives, adding Cordova Plug-Ins, running and testing the application in the browser and emulator up to finally running the application on an Android device and assembling files for a release. ...

May 3, 2015 · 13 min · 2648 words · Micha Kops

Immutables 2.0 for sexy Immutable Object Creation and more

Using immutable objects in Java (and other programming languages as well) is a good thing because immutable objects may be shared safely, are thread-safe and reduce the risk of side effects in your applications. Nowadays multiple frameworks exist to reduce the need of writing boilerplate code here but there is one special framework whose features I’d like to demonstrate in the following short tutorial. It hooks into your application using annotation processing and generates type-safe builders, toString, hashCode, equals methods for you, supports lazy attributes, singleton instances, serialization into data-formats like JSON and a lot of other features,too. ...

April 26, 2015 · 7 min · 1370 words · Micha Kops

Creating different Websocket Chat Clients in Java

Having written two articles about different websocket based chat server implementations in Java, I was recently asked how an implementation of the client side would look like in Java. That’s why I added this article to demonstrate how to create a websocket chat client applications within a few steps with the Java API for Websocket. In the following tutorial, we’re going to write a text-based chat client for the console first and afterwards we’re going to program a chat client with a graphical user interface, implemented in JavaFX. ...

November 9, 2014 · 10 min · 1937 words · Micha Kops