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

[Feature][3.3] Enhance JsonCompatibilityUtil to support triple protocol #13963

Open
3 of 4 tasks
AlbumenJ opened this issue Mar 20, 2024 · 6 comments
Open
3 of 4 tasks
Assignees
Labels
component/sdk Related with apache/dubbo help wanted Everything needs help from contributors type/enhancement Everything related with code enhancement or performance

Comments

@AlbumenJ
Copy link
Member

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

  • I had searched in the issues and found no similar feature requirement.

Apache Dubbo Component

Java SDK (apache/dubbo)

Descriptions

Enhance JsonCompatibilityUtil to support triple protocol none-annotation mode (application/json)

  • Check all the type that Dubbo can support
  • Generate the demo json struct
  • Log warn to notify users that this object might to compatiable with triple none-annotation mode

Related issues

No response

Are you willing to submit a pull request to fix on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

@AlbumenJ AlbumenJ added help wanted Everything needs help from contributors type/enhancement Everything related with code enhancement or performance component/sdk Related with apache/dubbo labels Mar 20, 2024
@hengyoush
Copy link
Contributor

I can try solve it, please assign to me

@CrazyHZM
Copy link
Member

@hengyoush Go ahead

@hengyoush
Copy link
Contributor

Before I start, I have some questions about this issue:

  • Check all the types that Dubbo can support: I guess the current JsonCompatibilityUtil already has the functionality to check the compatibility of classes. Is it the same usage as JsonCompatibilityUtil in RestProtocol, and should we also use JsonCompatibilityUtil to do the same thing in TripleProtocol?
// this is the JsonCompatibilityUtil in RestProtocol
private void checkJsonCompatibility(Class<?> clazz, String jsonCheckLevel) throws RpcException {

        if (jsonCheckLevel == null || JSON_CHECK_LEVEL_WARN.equals(jsonCheckLevel)) {
        //....
        List<String> unsupportedMethods = JsonCompatibilityUtil.getUnsupportedMethods(clazz);
        } else if (JSON_CHECK_LEVEL_STRICT.equals(jsonCheckLevel)) {
        // ...
        }
    }
  • Generate the demo json struct: Does JsonCompatibilityUtil need to generate corresponding sample JSON structures based on interface parameters during the validation process?

@AlbumenJ
Copy link
Member Author

AlbumenJ commented Apr 2, 2024

Before I start, I have some questions about this issue:

  • Check all the types that Dubbo can support: I guess the current JsonCompatibilityUtil already has the functionality to check the compatibility of classes. Is it the same usage as JsonCompatibilityUtil in RestProtocol, and should we also use JsonCompatibilityUtil to do the same thing in TripleProtocol?
// this is the JsonCompatibilityUtil in RestProtocol
private void checkJsonCompatibility(Class<?> clazz, String jsonCheckLevel) throws RpcException {

        if (jsonCheckLevel == null || JSON_CHECK_LEVEL_WARN.equals(jsonCheckLevel)) {
        //....
        List<String> unsupportedMethods = JsonCompatibilityUtil.getUnsupportedMethods(clazz);
        } else if (JSON_CHECK_LEVEL_STRICT.equals(jsonCheckLevel)) {
        // ...
        }
    }
  • Generate the demo json struct: Does JsonCompatibilityUtil need to generate corresponding sample JSON structures based on interface parameters during the validation process?
  • In TripleProtocol
  • No. This is a explict feature. @oxsean Do you have any ideas?

@hengyoush
Copy link
Contributor

Before I start, I have some questions about this issue:

  • Check all the types that Dubbo can support: I guess the current JsonCompatibilityUtil already has the functionality to check the compatibility of classes. Is it the same usage as JsonCompatibilityUtil in RestProtocol, and should we also use JsonCompatibilityUtil to do the same thing in TripleProtocol?
// this is the JsonCompatibilityUtil in RestProtocol
private void checkJsonCompatibility(Class<?> clazz, String jsonCheckLevel) throws RpcException {

        if (jsonCheckLevel == null || JSON_CHECK_LEVEL_WARN.equals(jsonCheckLevel)) {
        //....
        List<String> unsupportedMethods = JsonCompatibilityUtil.getUnsupportedMethods(clazz);
        } else if (JSON_CHECK_LEVEL_STRICT.equals(jsonCheckLevel)) {
        // ...
        }
    }
  • Generate the demo json struct: Does JsonCompatibilityUtil need to generate corresponding sample JSON structures based on interface parameters during the validation process?
  • In TripleProtocol
  • No. This is a explict feature. @oxsean Do you have any ideas?

I have completed the 1. and 3, but I am still confused about the second(Generate the demo json struct).
Assuming we have a class like:

 public class DemoClass {
      private String str;
      private Set<String> set;
  }

and get a String through String demoStruct = JsonCompatibilityUtil.generateDemoJsonStruct(Class clazz):

{
	"str": "foobar",
	"set": ["v1", "v2"]
}

Is my understanding correct?

@oxsean
Copy link
Collaborator

oxsean commented May 10, 2024

@AlbumenJ Sorry for later to noticed this
Should the focus be on leveraging JsonCompatibilityUtil in TripleProtocol to check compatibility? This should already be available. Generating the demo json structure may not be needed currently, but it could be useful for future support of OpenAPI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/sdk Related with apache/dubbo help wanted Everything needs help from contributors type/enhancement Everything related with code enhancement or performance
Projects
Status: Todo
Development

No branches or pull requests

4 participants