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

Attempt to create a cumulative fix for missing Object.h, AnyType.h, Set.h for many generators: can you give me some knowledge you have to help me correcting them? #18523

Open
mlebihan opened this issue Apr 28, 2024 · 2 comments

Comments

@mlebihan
Copy link
Contributor

mlebihan commented Apr 28, 2024

Many generators encounter the same problem against properties having a "type": "object" or 'type": ["string", "number",...], and another form with arrays that lead to missing sources files at generation time:

  • Object.h
  • AnyType.h
  • Set.h

being declared as #include but no Object.h, Object.cpp, AnyType.h, AnyType.cpp, Set.h, Set.cpp [for C++ example], are generated aside.

I am in need of correcting this problem, and I would like to solve it for the most generators possible. All, if possible.

They are already a lot of issues created for this trouble: one for one specific generator each time. But I think it's useful to gather here all the knowledge we have about it.


I begin focusing on it, and here's what I've attempted in a fork branch, to create a test that fails for the first of these problems:

master...mlebihan:openapi-generator:any_type
and I generate from a custom petstore, where I've added to Pet definition a:

        veterinarianVisit:
          type: object
          description: last veterinarian visit advice

Debugging things, it looks that C generator does generates its object.h and object.c files:

image

But cpp-pistache generator doesn't generate its equivalent Object.h and Object.cpp:

image

[main] ERROR org.openapitools.codegen.ObjectAnyTypeSetTest - Object.h expected file hasn't been produced by cpp-pistache-server generator.
[main] ERROR org.openapitools.codegen.ObjectAnyTypeSetTest - Object.cpp expected file hasn't been produced by cpp-pistache-server generator.

java.lang.AssertionError: 2 files ([Object.cpp, Object.h]) are lacking in cpp-pistache-server generation
Expected :true
Actual   :false
<Click to see difference>


	at org.testng.Assert.fail(Assert.java:110)
	at org.testng.Assert.failNotEquals(Assert.java:1413)
	at org.testng.Assert.assertTrue(Assert.java:56)
	at org.openapitools.codegen.ObjectAnyTypeSetTest.assertGeneratedFiles(ObjectAnyTypeSetTest.java:72)
	at org.openapitools.codegen.ObjectAnyTypeSetTest.testSomeWithPetstoreWithAbstract(ObjectAnyTypeSetTest.java:45)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:135)
	at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:673)
	at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:220)
	at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
	at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:945)
	at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:193)
	at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
	at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.testng.TestRunner.privateRun(TestRunner.java:808)
	at org.testng.TestRunner.run(TestRunner.java:603)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:429)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:423)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:383)
	at org.testng.SuiteRunner.run(SuiteRunner.java:326)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1249)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
	at org.testng.TestNG.runSuites(TestNG.java:1092)
	at org.testng.TestNG.run(TestNG.java:1060)
	at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:65)
	at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:105)

Depending on the issues I've read about this, they are various advices. Can you tell me:

  1. If once, these sources were generated but an event (around 4.1.0 version of openapi generator? earlier?) made that it doesn't work anymore?

  2. If it's just a configuration issue : the missing sources exist (for each generator) but they just aren't "pushed" at generation time, for any reason ; or if at the opposite, they are entirely missing? "We don't know yet (we haven't written yet), in example, how to perform a C++ serialization in json of an Object?

  3. What do you recommend me, to solve this problem?

Thanks!

@mlebihan mlebihan changed the title Attempt to create a cumulative fix for missing Object.h, AnyType.h, Set.h for many generators: can you give me all the knowledge you have about how to correct them? Attempt to create a cumulative fix for missing Object.h, AnyType.h, Set.h for many generators: can you give me some knowledge you have to help me correcting them? Apr 28, 2024
@wing328
Copy link
Member

wing328 commented Apr 28, 2024

@mlebihan thanks for offering help to fix these issue. Can you please PM me via Slack when you've time in the coming week?

https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g

@mlebihan
Copy link
Contributor Author

mlebihan commented May 1, 2024

Object for C++ pistache looks working correctly with:

master...mlebihan:openapi-generator:any_type

(my test isn't accurate and working, but the generation looks to be)

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

2 participants