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

Type K (+TypeVariableImpl) is not supported yet. #138

Open
landon-L opened this issue May 8, 2024 · 13 comments
Open

Type K (+TypeVariableImpl) is not supported yet. #138

landon-L opened this issue May 8, 2024 · 13 comments

Comments

@landon-L
Copy link

landon-L commented May 8, 2024

How to display detailed logs when encountering this prompt, "Type K (+TypeVariableImpl) is not supported yet."

@kbuntrock
Copy link
Owner

Hello @landon-L .

You can use the "-X" option. Ex : mvn compile -X

May I ask which version of the plugin are you using?

@kbuntrock
Copy link
Owner

Hello @landon-L. Do you have any more information about this bug? Which version of the plugin are you using?

@avk458
Copy link

avk458 commented Sep 2, 2024

I've encountered this error using version of 0.0.20. I can't find additional information about the error, even after narrowing down to a specific RestController.

[INFO] Reflections took 1629 ms to scan 278 urls, producing 2 keys and 2 values
[INFO] Found 1 annotated classes with [ RequestMapping ]
[DEBUG] Parsing tag : ContractReportController
[DEBUG] Parsing endpoint ContractReportController
[DEBUG] Parsing request method : getContractRelate2ReportList
[DEBUG] Reading parameters from getContractRelate2ReportList
[DEBUG] Parameter : id
[DEBUG] PathVariable annotation detected (id)
[DEBUG] Parameter : query
[DEBUG] DataObject{openApiType=io.github.kbuntrock.utils.OpenApiResolvedType@54e2115e, arrayItemDataObject=null}
[DEBUG] Finished parsing endpoint : getContractRelate2ReportList - GET
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:36 min
[INFO] Finished at: 2024-09-02T17:30:48+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.github.kbuntrock:openapi-maven-plugin:0.0.20:documentation (documentation) on project ilis2: Execution documentation of goal io.github.kbuntrock:openapi-maven-plugin:0.0.20:documentation failed: Type K (+TypeVariableImpl) is not supported yet. -> [Help 1]

@avk458
Copy link

avk458 commented Sep 5, 2024

Turns out, I have a model class that extends the HashMap<String, Object>, this will resolve to OpenApiDataType.OBJECT. So that when add the dataobject to the TagLibrary, it will inspected as an object. The K TypeVariable comes from the AbstractMap.
I believe the root cause is that the static type analysis cannot handle generic types.

I'm willing to help.

@kbuntrock
Copy link
Owner

kbuntrock commented Sep 6, 2024

Hello @avk458

Thank you very much for the bug report / analysis.

It would help me if you create a PR with a test in error reproducing your case.
Then I can complete it and focus on the bug resolution.

Generics are the biggest burden of this project and it is not the simplest section to re-dive into after two years. :p

On a side note, I'm currently in holidays very far away from home till the end of the month. So I'll not be able to work on it until then. Hope this can wait for you. :(

@avk458
Copy link

avk458 commented Sep 11, 2024

@kbuntrock I noticed that #144 already has a PR that is similar to my case.

Have a nice trip. :)

@kbuntrock
Copy link
Owner

Hello @avk458 .

I'm currently working on your problem. Even though it looks similar to the issue #144, this is not exactly the same case.

Could you provide an example of your custom model class extending an hashmap - associated with the partial openapi documentation you would expect for this class?

Thank you by advance and wish you a good day!

Kind regards,
Kevin

@kbuntrock
Copy link
Owner

@landon-L I know it's been a long time ... Can I abuse of your time a little more and ask you to try the current 0.0.22-SNAPSHOT (it require a local "install", like "mvn clean install -DskipTests" for example).

I should have fixed your issue.

PS : @avk458 : can you try it too?

@avk458
Copy link

avk458 commented Nov 7, 2024

If you define a type like this

public class Pager<T> extends HashMap<String, Object> {
    public <T> Pager<T> rows(List<T> rows) {
        this.put("rows", rows);
        return this;
    }
}

This error will raise Type E (+TypeVariableImpl) is not supported yet.

@kbuntrock
Copy link
Owner

If you define a type like this

public class Pager<T> extends HashMap<String, Object> {
    public <T> Pager<T> rows(List<T> rows) {
        this.put("rows", rows);
        return this;
    }
}

This error will raise Type E (+TypeVariableImpl) is not supported yet.

Thanks, looking into it.

@kbuntrock
Copy link
Owner

kbuntrock commented Nov 10, 2024

If you define a type like this

public class Pager<T> extends HashMap<String, Object> {
    public <T> Pager<T> rows(List<T> rows) {
        this.put("rows", rows);
        return this;
    }
}

This error will raise Type E (+TypeVariableImpl) is not supported yet.

This example was not compiling.

I extrapolated it to something like this in order to have the two possibilities I can imagine:

public class Pager<T> extends HashMap<String, Object> {

	public Pager<T> rows(List<T> rows) {
		this.put("rows", rows);
		return this;
	}

	public <G> Pager<T> lines(List<G> lines) {
		this.put("lines", lines);
		return this;
	}
}

Even though this example was not working (now fixed), I did not stumble on the same error.

Could you pull again locally the current dev version, build and install it locally (like with "mvn clean install -DskipTests" for example), and try the current local "0.0.22-SNAPSHOT" in your projet?

@avk458
Copy link

avk458 commented Nov 11, 2024

In a particular case like the one Pager above, the current version is working correctly. However, when I target the whole project, the error variable type K or E continues emerge. (The project I'm working on is old and sort of ugly)
By the way, empty-valued-parameter haven't been supported yet.
Mappings like below will fail to generate documents due to duplicated entry:

@PostMapping(value = "devices/command", params = "SWITCH_ON")
public void switchOn() {
    // mothod x
}

@PostMapping(value = "devices/command", params = "SWITCH_OFF")
public void switchOff() {
    // mothod y
}

I wish I had more time to make a PR.

@kbuntrock
Copy link
Owner

In a particular case like the one Pager above, the current version is working correctly. However, when I target the whole project, the error variable type K or E continues emerge. (The project I'm working on is old and sort of ugly) By the way, empty-valued-parameter haven't been supported yet. Mappings like below will fail to generate documents due to duplicated entry:

@PostMapping(value = "devices/command", params = "SWITCH_ON")
public void switchOn() {
    // mothod x
}

@PostMapping(value = "devices/command", params = "SWITCH_OFF")
public void switchOff() {
    // mothod y
}

I wish I had more time to make a PR.

Hello.

No worries about your time, I'm glad you're providing me valuable information about ways to improve this plugin.
I'm currently working on the issue #169 and I see some similarities with your "switch on / off" use case. I will implement it in the same PR.

I'll also try to make generic errors causes easier to spot.

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

No branches or pull requests

3 participants