Let's Build an API Together - Part 29 - kanbanbackend.com

Last Update: 12.02.2018. By Jens in API Series | APIs | Newsletter

I’ve been working on the Kanban tutorial app to make it a better tutorial application. This week, I am going to talk about changes and why and how I implemented them.

Also, I’ve created the kanban backend site to showcase tech stacks for building a more complex API then todo backend provides. Furthermore, I plan on adding more implementations myself and also creating a version for showcasing single-page applications like todomvc does for a simple todo app. Feel free to join in and code a backend in whatever stack you like.

Now, let’s take a look at what we will cover:

  • Adding your own APIError classes and return JSON errors even with Spring Security
  • Enabling CORS
  • How to return validation errors and mapping from Spring binding errors
  • Adding swagger for API docs
  • Remember reserved keywords

I’ll start today with the last one of the list: Remember reserved keywords

Until now I developed the whole API against the h2 DB, and everything went fine. However, for the backend site, I deployed it to Heroku and used Postgres. Unfortunately, Postgres does now like tables and fields named user, so it could not create the table for the User entity.

It is an easy fix though, just define the name of the table in the @Table annotation like:

public class User implements Serializable{ //rest...}

And on a column, use the name parameter of @Column annotation like:

private Long user;

Eadsy peasy, just remember it :-)

Want content like this in your inbox each workday irregularly? No BS, spam or tricks... just useful content:

I understand and agree to the privacy policy