Commit e8d7ddb3 authored by Noel Alonso's avatar Noel Alonso
Browse files

Añade nueva etiqueta para relaciones tipo uuid

parent 65b3cf94
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
package com.kjetland.jackson.jsonSchema.annotations;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target({ METHOD, FIELD, PARAMETER, TYPE })
@Retention(RUNTIME)
public @interface JsonSchemaUrlUuid {
    String value();
}
+13 −1
Original line number Diff line number Diff line
@@ -982,13 +982,25 @@ class JsonSchemaGenerator
                            Option(p.getAnnotation(classOf[JsonSchemaUrl])).map(_.value())
                        }.map {
                          url =>
                            setType(thisPropertyNode.meta, prop, "string")
                            setType(thisPropertyNode.meta, prop, "integer")
                            //thisPropertyNode.meta.put("type", "integer")
                            thisPropertyNode.meta.put("url", resources.properties.get(url).getOrElse("none"))
                            thisPropertyNode.meta.remove("$ref")
                            removeDefinition(propertyType)
                        }

                        // Optionally add url uuid
                        prop.flatMap {
                          p: BeanProperty =>
                            Option(p.getAnnotation(classOf[JsonSchemaUrlUuid])).map(_.value())
                        }.map {
                          url =>
                            setType(thisPropertyNode.meta, prop, "string")
                            thisPropertyNode.meta.put("url", resources.properties.get(url).getOrElse("none"))
                            thisPropertyNode.meta.remove("$ref")
                            removeDefinition(propertyType)
                        }

                      }
                      else {
                        removeDefinition(propertyType)