Skip to content

server attribute requestLog does not allow snake case #1558

Closed

Description

@camerondavison

in Dropwizard version 1.0.0-rc2 currently

marks the name of the requestLog property to be explicitly camel case. I am using the SNAKE_CASE jackson extension and it is very un-intuitive to have one random property that is not snake case.

In my app initialize I am doing

bootstrap.getObjectMapper().setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);

so that all jersey requests with json use snake case (which affects the configuration as well)

Activity

  1. nickbabcock commented on May 24, 2016

    @nickbabcock
    Contributor

    The problem is that the @JsonProperty("requestLog") is needed, else it won't be de/serialized correctly because the property is named differently than what would be auto-detected.

    @JsonProperty("requestLog")
    public RequestLogFactory getRequestLogFactory() {
        return requestLog;
    }

    And unfortunately the naming strategy only works in:

    in cases where they are not auto-detected and no explicit annotations exist for naming [docs]

    If there was a way to get the snake casing to work universally without breaking backwards compatibility, I would support that (have you tried mixins?)

  2. camerondavison commented on May 24, 2016

    @camerondavison
    Author

    Ah, I think because of 05d3fcd I thought that this was new. This problem has been around for a while. Maybe you could do something like

    /*package*/ void setRequestLog(RequestLogFactory requestLog) {
        this.requestLog = requestLog;
    }
    

    making it package local, so that jackson could use it, but not breaking any other people that are using the java apis.

  3. nickbabcock commented on Sep 25, 2016

    @nickbabcock
    Contributor

    In the boostrapper you should be able to enable a feature on the mapper that allows for naming strategy to override the JsonProperty

    mapper.enable(MapperFeature.ALLOW_EXPLICIT_PROPERTY_RENAMING);

    From the javadocs:

    Feature that when enabled will allow explicitly named properties (i.e., fields or methods annotated with JsonProperty("explicitName")) to be re-named by a PropertyNamingStrategy, if one is configured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions