Coder Social home page Coder Social logo

Remove JaxRS dependency about problem HOT 10 CLOSED

cbornet avatar cbornet commented on August 16, 2024
Remove JaxRS dependency

from problem.

Comments (10)

cbornet avatar cbornet commented on August 16, 2024 1

@whiskeysierra yes, you're right. Switching to int (Integer ?) would probably be the best since only the code is serialized.
Do I PR ?

from problem.

cbornet avatar cbornet commented on August 16, 2024 1

I think 2/ is nicer for the end-user since he gets the status code meaning instantly.
As for maintaining the enum, I think it's not a big deal since we can provide the most commonly used statuses and people who use exotic ones can easily add them in their own code (just like what is done in JAX-RS). They will even enjoy the java8 default methods of the interface (which is not the case with JAX-RS).
I'll do the PR based on 2/ then we can discuss on it if you're OK.

from problem.

whiskeysierra avatar whiskeysierra commented on August 16, 2024

It seems to me that only the Status/StatusType classes are used from JAX-RS.

Correct.

This doesn't represent a lot of code so it would be easy to duplicate. Also, it's always nice to remove a dependency and will make the lib smaller.

Yes, but that would be a breaking change. That would at least require that we also do this change in zalando/problem-spring-web.

from problem.

whiskeysierra avatar whiskeysierra commented on August 16, 2024

In general I'd be fine with switching from StatusType to int.

from problem.

whiskeysierra avatar whiskeysierra commented on August 16, 2024

Do I PR ?

It would be highly appreciated!

from problem.

cbornet avatar cbornet commented on August 16, 2024

Do you prefer Integer (+ static constants) or enum ?

from problem.

whiskeysierra avatar whiskeysierra commented on August 16, 2024

I think Integer without any static constants should be enough. I don't want to maintain a complete list and enum would be too restricting since it needs to be extensible as dictated by the RFC.

from problem.

cbornet avatar cbornet commented on August 16, 2024

The reasonPhrase is used in GenericProblems to set the Problem title.
What should I do about it ?

Abou enum extensibility, we can use an interface like StatusType. So users can add there own status enum by implementing it.

from problem.

whiskeysierra avatar whiskeysierra commented on August 16, 2024

The reasonPhrase is used in GenericProblems to set the Problem title.
What should I do about it ?

Good question. Maintaining a list of status code + reason phrases is equivalent to maintaining a complete status enum itself. Something that I'd like to avoid.

Abou enum extensibility, we can use an interface like StatusType. So users can add there own status enum by implementing it.

Yes, that's true. In fact I used JAX-RS for this very reason. And because it contained an enum already that I didn't have to maintain myself.

I'm torn between the following two options:

  1. a simple int (or Integer), no reason phrase, no enum/dictionary of statuses that we need to maintain
  2. an interface + an enum of defaults, that introduces a new place where status codes are defined (in addition to JAX-RS, Spring, ...). But you get typed status objects + reason phrases.

I see good arguments for both. Which one do you prefer?

from problem.

whiskeysierra avatar whiskeysierra commented on August 16, 2024

I'll do the PR based on 2/ then we can discuss on it if you're OK.

Sounds good!

from problem.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.