Sérgio Serra
Sérgio Serra

Reputation: 27

Attribute HAL Explorer - Spring Boot

In Spring Boot, the 'password' attribute doesn't appear in the HAL explorer due to the @Transient and @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) annotations. I'd like the 'password' to appear in the POST form so I don't have to remember all the attributes since there are several services.

enter image description here

@Entity
@Table(name = "organizations")
@Data
public class Organization {

    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    private UUID id;

    @NotBlank(message = "Name is mandatory")
    @Pattern(regexp = "^[a-zA-Z0-9_-]{3,16}$",
            message = "Name must contain 3 to 16 characters and can only contain letters, numbers, underscores, and hyphens")
    private String name;

    @NotBlank(message = "OrgCode is mandatory")
    private String orgCode;

    @NotBlank(message = "Eac is mandatory")
    private String eac;

    @NotBlank(message = "Country is mandatory")
    private String country;

    @NotBlank(message = "Password is mandatory")
    @Pattern(regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$",
            message = "Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one digit, and one special character")
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @Transient
    private String password;

}

I'm using Spring Data Rest.

@RepositoryRestResource
interface MetricRepository extends JpaRepository<Metric, UUID> {}

I already tried following the steps below.

https://docs.spring.io/spring-data/rest/reference/representations.html

https://docs.spring.io/spring-data/rest/reference/customizing/custom-jackson-deserialization.html

I'd like to retrieve the 'password' attribute in the HAL explorer within the form.

Upvotes: 0

Views: 73

Answers (0)

Related Questions