Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add issues support in serializer and createHttpException #675

Merged
merged 3 commits into from
Oct 28, 2023

Conversation

belgattitude
Copy link
Owner

Add support for HttpUnprocessableEntity.issues in serializer.

import { fromJson, toJson } from '@httpx/exception/serializer';

const e422 = new HttpUnprocessableEntity({
    message: 'Validation failed',
    issues: [
        {
            message: 'Invalid address',
            path: ['addresses', 0, 'line1'],
            code: 'empty_string',
        },
    ],
});

const json = toJson(e422);
const js = fromJson(json);

expect((js as HttpUnprocessableEntity).issues).toStrictEqual(e422.issues);
expect(js).toStrictEqual(e422);

And Fix createHttpException that wasn't allowing issues on HttpUnprocessableEntity

const e422 = createHttpException(422, {
    message: 'Validation failed',
    issues: [
        {
            message: 'Invalid address',
            path: ['addresses', 0, 'line1'],
            code: 'empty_string',
        },
    ],
});

@changeset-bot
Copy link

changeset-bot bot commented Oct 28, 2023

🦋 Changeset detected

Latest commit: 57e06d1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@httpx/exception Minor
@examples/nextjs-app Patch
@httpx/json-api Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

# Conflicts:
#	packages/exception/.size-limit.cjs
#	packages/exception/src/client/HttpUnprocessableEntity.ts
@ghost
Copy link

ghost commented Oct 28, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@codecov
Copy link

codecov bot commented Oct 28, 2023

Codecov Report

Merging #675 (57e06d1) into main (5ed840e) will increase coverage by 2.31%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #675      +/-   ##
==========================================
+ Coverage   90.87%   93.18%   +2.31%     
==========================================
  Files          74       74              
  Lines         482      484       +2     
  Branches      118      119       +1     
==========================================
+ Hits          438      451      +13     
+ Misses         38       28      -10     
+ Partials        6        5       -1     
Flag Coverage Δ
httpx-dsn-parser-unit 100.00% <ø> (ø)
httpx-exception-unit 95.25% <100.00%> (+3.31%) ⬆️
httpx-json-api-unit 66.00% <ø> (ø)
Files Coverage Δ
...es/exception/src/client/HttpUnprocessableEntity.ts 100.00% <ø> (ø)
...kages/exception/src/factory/createHttpException.ts 100.00% <100.00%> (ø)
...ion/src/serializer/mapper/convertToSerializable.ts 95.45% <100.00%> (+0.21%) ⬆️
...on/src/serializer/mapper/createFromSerializable.ts 92.30% <100.00%> (+0.20%) ⬆️

... and 2 files with indirect coverage changes

@belgattitude belgattitude merged commit a6a63e1 into main Oct 28, 2023
9 checks passed
@belgattitude belgattitude deleted the serialize-support-422 branch October 28, 2023 16:57
@belgattitude belgattitude mentioned this pull request Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant