-
Notifications
You must be signed in to change notification settings - Fork 14
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
Model Substitution #98
Comments
This is a very good point. Was thinking about it recently since I cannot know in advance every future java class which need a different mapping (like BigDecimal, LocalDateTime, ...). Do you want this functionality in the 0.0.17 release? (can take me a few days since I have some plans for my evenings this week. ;) ) |
I'm OK with having it in version 18 |
BTW this format that I've showed you is only for example. Personally I think it's terrible. I think that something like this would be better: <modelSubstitutions>
<modelSubstitution>
<from>com.acme.HumanIdDto</from>
<to>java.lang.Integer</to>
<modelSubstitution>
</modelSubstitutions> |
Any update on this? |
Code wise, now, but I thought about it this week. :) |
Can you just release this feature and later add new things? I need this for
my work 😉
niedz., 5 lis 2023, 19:17 użytkownik Kévin Buntrock <
***@***.***> napisał:
… Code wise, now, but I thought about it this week. :)
I'm thinking about going a bit further and opening more the generator.
—
Reply to this email directly, view it on GitHub
<#98 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAWTLHXYTOLKKB52YEOIXQLYC7J5HAVCNFSM6AAAAAA6V2AWAOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTHAYDQNRVG4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
It's more about the time I have to allow to this project. :) But I'll try to work on it tomorrow evening. |
Hello @magx2 ! Busy week, lot of work and I'll not be able to work on it today. But I still think about you! If you really need an emergency release, you can start from your copy of the plugin and modify the OpenApiDataType#fromJavaClass function to directly put your model substitution. <pluginRepositories>
<pluginRepository>
<id>repo</id>
<url>file://${project.basedir}/project_m2</url>
</pluginRepository>
</pluginRepositories> I know it's not perfect, but maybe it can help you to wait more peacefully the next release. :) Wish you a good evening. |
Thanks! It works as a temporary solution, but still I need the fix ;) |
Any update on this? |
Yes, I was able to work on it this weekend. Still missing in my MR :
|
Hey, any update on this? |
So sorry Martin, time is flying so fast. A more realistic time of arrival
will be Christmas then since I'm planning to take a few days off.
Le mar. 12 déc. 2023, 15:28, Martin ***@***.***> a écrit :
… Hey, any update on this?
—
Reply to this email directly, view it on GitHub
<#98 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADUBIHHOVAXCW32GAAGV7ZTYJBS2RAVCNFSM6AAAAAA6V2AWAOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJSGE2DKNBRGE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
FYI: Please make sure that mapping from class to class (not primitive) also works. Previously I did some fast PoC for mapping object to primitive ( I think it would be good if you would have test for those cases:
|
Hey, do you have a branch with this functionality? Maybe I can build it locally and use it for now. |
? |
Hey, did you had time to fix it? |
I've got this, but it is still not finished. Focusing on it for my new year resolutions so you can try it : https://github.com/kbuntrock/openapi-maven-plugin/pull/104/files As you can see, I'm driving this in a different path than the kongchen plugin. The openapi-model.yml is the file describing defaults types models (mainly the type / format pairs) Then there is the default "model-association.yml" file, describing how to link a java class to a model. And if it's by "equality" or "assignability". It can also be extended / partially replaced. I'm not planning to handle scenario number 4. Do you have use cases for it? |
Awesome! Good that you are back in the game 😁. I will take a look on your PR tommorow. About point 4 - I don't have a use case of it. I was just listing all possibilities. After thinking about it in my opinion there is no use case for mapping array to object. |
Better to not dig into it then, it would be a genericity nightmare. |
right? |
We can for sure now say it will not be for December. :) Working on it. |
Hello @magx2. I've finally reached a point I'm keen to merge. But I first need to check if it fulfil your needs. I have not yet wrote the documentation so I write here a draft to help you. The class mapping is now based on two configuration files : Secondly, the mapping between descriptions and scanned class : The two linked files are the default ones, shipped with the plugin. But one can add an extra mapping file with the option And even an extra model file for more complex use cases with the following option : Please tell me if it check your use case. And don't hesitate if you need an example of usage. Sorry for the long development time and I wish you a good evening. :) |
I have a question: Why did you introduced 2 new files instead of having the configuration in pom.xml? |
And another question: I have a class |
I've added it to my project and it looks good. I'm not supper happy with extra files (you could map the same thing in pom.xml configuration), but if you prefer it then it's fine |
Running out of time tonight. Thank you very much for your time spent testing and reading my PR. |
Hello @magx2. Here some answers to your questions.
The model file can describe complex types. For this one, I thought describing them in yml is easier. And yml + xml mix terribly. But I like your suggestion. As for the freeFields or the default error section, I'll allow to write a definition in json in the xml, or to reference a file.
You can't. Imagining the potential use cases, I'm convinced mapping a class to another class is primarily used to map a forgotten/custom class. Here, we can map forgotten class (as you have seen with ZonedDateTime), but we can also create complete custom objects. But I can be wrong. What about your use case? You really need to remap a class by another class? |
I think you are able to do this without mixing yml and xml
It's just not to write open api yml myself but rather leave it to the plugin. I was able do it so you can ignore this request. |
Let say I have object:
and endpoint:
By default your plugin will create an
HumanIdDto
object that contains only one field which is technically OK, but it generates "stupid" objects in API.Can you add some kind of mapping objects to other object, i.e.:
In this case java class
HumanIdDto
will be represented asInteger
in Open API. Here you have example of plugin for Swagger 2: https://github.com/kongchen/swagger-maven-plugin#sample-model-substitutionThe text was updated successfully, but these errors were encountered: