Skip to content

Escaping API inconsistencies #1577

Description

@jonatan-ivanov

If I understand correctly, this is approximately how I should produce an output:

expositionFormats.findWriter(accept)
    .write(System.out, registry.scrape(), EscapingScheme.fromAcceptHeader(accept));

The problem with this is that the API forces me to pass the accept header twice, so theoretically I can do this:

expositionFormats.findWriter(acceptHeaderOne)
    .write(System.out, registry.scrape(), EscapingScheme.fromAcceptHeader(acceptHeaderTwo));

Which can lead to inconsistencies, it is easy to misuse the API.
I'm wondering if something like this would make sense:

expositionFormats.findWriter(accept).write(System.out, registry.scrape());

and the writer would have the EscapingScheme.
The writer still can be cached but it would be a little more than today.

Activity

  1. zeitlinger commented on Sep 19, 2025

    @zeitlinger
    Member

    So we'd need to add the escaping scheme to the writer - creating ExpositionFormatWriterWithEscaping.

    If more users fall into this trap, then I'll consider adding this new API.

  2. github-actions commented on Sep 15, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 12 months of inactivity. It will be automatically closed if there is no further activity over the next 30 days.

  3. jonatan-ivanov commented on Sep 15, 2026

    @jonatan-ivanov
    ContributorAuthor

    I think this is still valid.

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