Skip to content

feat: add an option to disable throwing an error when !request.ok #297

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

Merged
merged 2 commits into from
Oct 4, 2021

Conversation

RoCat
Copy link
Contributor

@RoCat RoCat commented Sep 27, 2021

In my app i have a lot of "normal" HTTP errors (e.g. 404 when no "object" found etc...).
It's a pain to alway surround API call with try / catch (or then / catch) to avoid code crash when a simple if(response.ok) will be enough.

I added "disableThrowOnError" option to remove the throw error behavior on fetch-http-client.
Default value is false, then the current behavior remain unchanged.

@js2me
Copy link
Member

js2me commented Sep 27, 2021

Hello @RoCat ! Thanks for this feature request, can you switch target branch from master to next ?

@RoCat RoCat changed the base branch from master to next September 28, 2021 07:33
@RoCat
Copy link
Contributor Author

RoCat commented Sep 28, 2021

Hi, change done ;)

@js2me
Copy link
Member

js2me commented Sep 29, 2021

Thank you!

@js2me js2me merged commit 5e24567 into acacode:next Oct 4, 2021
grandsilence pushed a commit to grandsilence/swagger-typescript-api-nextgen that referenced this pull request May 16, 2022
js2me added a commit that referenced this pull request Aug 15, 2022
* Feature: allow passing "patch" option to "swagger2openapi" (#283)

Co-authored-by: cassel <[email protected]>

* Loads prettier config from user's project (#286)

* fix: problem with missing HttpResponse type with --to-js option

* fix: missing extractRequestBody field in type

* fix(reject): fix reject and exit with code 1 if error (#295)

* fix(reject): fix reject and exit with code 1 if error

* feat: add a parameter to sort types and types properties (#299)

Co-authored-by: rcatoio <[email protected]>

* feat: add an option to disable throwing an error when request.ok is not true (#297)

Co-authored-by: rcatoio <[email protected]>
Co-authored-by: Sergey S. Volkov <[email protected]>

* fix: fix missing `title` of object type (#303)

* chore: refresh auto generated code; chore: add axios to dev deps

* bump: up to 9.3.0

* bump: up to 9.3.1; fix: axios

* chore: fix typo (#376)

* 304 Support readOnly properties (#365)

* allow mutually exclusive input options (#327)

Co-authored-by: Sergey S. Volkov <[email protected]>

* Update fetch-http-client.eta (#329)

* BREAKING_CHANGE: add --extract-response-body option; bump: version to 9.4.0

* feat: added authorization token to headers
Co-authored-by: MarcinFilipek <[email protected]>

* feat: --extract-response-error option

* chore: refresh code gen tests

* fix: change COMPLEX_NOT_OF to COMPLEX_NOT (#356)

* Fix request format and allow for files in request - With code review changes (#350)

* fix pick format
allow for file array in form data requests

* fixed code review suggestions

Co-authored-by: Daniele De Matteo <[email protected]>
Co-authored-by: Sergey S. Volkov <[email protected]>

* Pass through required properties to allOf/anyOf/oneOf children (#342)

* Pass through required properties to allOf children

* extend fix to anyOf and oneOf

* fix: account for children making parent fields required

Co-authored-by: Anders Cassidy <[email protected]>
Co-authored-by: Daniel Playfair Cal <[email protected]>
Co-authored-by: Sergey S. Volkov <[email protected]>

* Add option to change main Api class name (#320)

* Update api.eta

* Update index.d.ts

* Update index.js

* Update index.js

* Update config.js

Co-authored-by: Sergey S. Volkov <[email protected]>

* fix: missing stringifyFormItem method; bump: up version to 10.0.0

* docs: update docs, changelog, fix: problem with complex types (makeAddRequiredToChildSchema)

Co-authored-by: Xavier Cassel <[email protected]>
Co-authored-by: cassel <[email protected]>
Co-authored-by: Adrian Wieprzkowicz <[email protected]>
Co-authored-by: EvgenBabenko <[email protected]>
Co-authored-by: RoCat <[email protected]>
Co-authored-by: rcatoio <[email protected]>
Co-authored-by: 卡色 <[email protected]>
Co-authored-by: 江麻妞 <[email protected]>
Co-authored-by: Kasper Moskwiak <[email protected]>
Co-authored-by: Ben Watkins <[email protected]>
Co-authored-by: bonukai <[email protected]>
Co-authored-by: baggoedw <[email protected]>
Co-authored-by: Marcus Dunn <[email protected]>
Co-authored-by: Daniele De Matteo <[email protected]>
Co-authored-by: Daniel Playfair Cal <[email protected]>
Co-authored-by: Anders Cassidy <[email protected]>
Co-authored-by: Daniel Playfair Cal <[email protected]>
@hognevevle
Copy link

hognevevle commented Sep 23, 2022

Would love to see this option added to generateApi as well 🥳

EDIT: Actually, it seems to be working already, it's just missing from the typescript declaration (index.d.ts).

@arashi-dev
Copy link

It still isn't in the type definitions

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.

4 participants