Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is the ProblemDocument class really neessary? #34

Open
Open
Is the ProblemDocument class really neessary?#34

Description

Working some more with this and related libraries I'm repeatedly thinking whether the ProblemDocument really needs to be a class?

Wouldn't it be enough to simply define a contract for a problem document and have mapper return plain objects?

interface ProblemDocument extends Record<string, unknown> {
detail?: string;
instance?: string;
status: number;
title: string;
type?: string;
}

class Mapper {
mapError(error): ProblemDocument {
return {
status: 500,
title: 'Something happened'
}
}
}

This would simplify how extensions are implemented and make it easier to work with derived or decorated mappers

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