package com.devskiller.friendly_id.spring;

import java.util.UUID;

import com.fasterxml.jackson.databind.Module;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.devskiller.friendly_id.FriendlyId;
import com.devskiller.friendly_id.jackson.FriendlyIdModule;

@Configuration
public class FriendlyIdConfiguration extends WebMvcConfigurerAdapter {

	@Override
	public void addFormatters(FormatterRegistry registry) {
		registry.addConverter(new StringToUuidConverter());
		super.addFormatters(registry);
	}

	@Bean
	public Module friendlyIdModule() {
		return new FriendlyIdModule();
	}

	//FIXME: make this public
	public static class StringToUuidConverter implements Converter<String, UUID> {

		@Override
		public UUID convert(String id) {
			return FriendlyId.toUuid(id);
		}
	}
}

@@ -734,16 +734,70 @@
 ter());%0A
+%09%09registry.addConverter(new UuidToStringConverter());%0A
 %09%09super.
@@ -1100,10 +1100,186 @@
 %0A%09%09%7D%0A%09%7D%0A
+%0A%0A%09public static class UuidToStringConverter implements Converter%3CUUID, String%3E %7B%0A%0A%09%09@Override%0A%09%09public String convert(UUID id) %7B%0A%09%09%09return FriendlyId.toFriendlyId(id);%0A%09%09%7D%0A%09%7D%0A
 %7D%0A

Add UUID to string Spring converter