-
Notifications
You must be signed in to change notification settings - Fork 121
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
Support array of objects in YAML property files #216
Comments
It certainly isn't expected for it to fail in this manner. Since MP Config deals in strings, the value is meant to to be converted to a list of key-value pairs. We don't have any map converters yet (just because there hasn't been a use case yet). |
This should fix the Stackoverflow issue: Regarding support for Arrays of Objects or Maps is another story. I recommend that we open a separate issue for that. |
Thank you very much! |
Actually, I'll leave this one open and create a new issue for the Stackoverflow problem. |
@dmlloyd how can we register custom converters at quarkus? I currently have an use case where I need to decode a collection of objects via quarkus. EDIT: Eventually I was puzzled by the distributed docs and looked at the wrong place. The answer is there: https://quarkus.io/guides/config#custom-configuration |
Hi @rolandjohann, you can register converters in Quarkus per the definition of MP Config. Please check here on how to do it: |
@radcortez thanks for the quick answer. Remembered that section previously. The converter turns out to be pretty useless as the string representation contains key value pairs but the delimiter is missing. When using different levels of nesting it gets more confusing. Is it possible to implement confiuration schemas like that posted by op? de:
javahippie:
mpadmin:
instances:
-
name: "Bing"
uri: "https://bing.com"
-
name: "Google"
uri: "https://www.google.com" |
Yes, that is something that we need to figure out. I'll try to have a look on how we can implement this. Also, we would love help if you want to contribute that piece :) |
Sure, but I need some guidance here as the internals of smallrye are pretty unknown to me |
Thanks! Try to have a look into the project and I'll help as much as I can. Probably, you should start by looking into: |
What do you mean by "missing"? |
He means that:
When mapped to Worse, as you can see in my example, I used a nested list, and if we now map that config tree to
This wasn't unexpected though. |
That is definitely a bug... the code is supposed to insert the right number of escapes based on the nesting level, but there must be a logic error that occurs when going from list to map. |
OK I'm definitely willing to take a look when I'm done with my current project...say within a week. |
Cool. Looking forward for your PR. Thanks! :) |
I have been looking into this and I think we should change a little bit on how we do things. When we have a simple case, where the yaml end nodes can be translated 1 to 1 to property keys everything is ok. The issue is when we mix Maps and Lists that don't translate directly to a single unique key. In the case, the value was going into a single key with several escapes that required the consumer to parse. Well, what if we just keep it in the original format which is easier to convert? :) Also we could add additional indexed keys that allow to retrieve values from lists. Please have a look in here #335 and let me know any feedback. @fabmars @javahippie @rolandjohann |
Description
I am using Smallrye Config via Quarkus 1.1.0.
Using arrays in application.yaml currently works fine for single values like this:
I can access the property without any additional configuration as a list of strings. I was curious if it was possible to write my own converter for a list of objects, as I need more data in my application than just the urls, and tried this:
This is valid YAML and something that works in Spring Boot, when using a YAML as a property file. However, when I try to run Quarkus dev mode, it throws an exception:
Would it be possible to implement a feature like this with a MicroProfile Config source? If no custom converter is provided, this could be interpreted as a
List<Map<String, String>>
as default?The text was updated successfully, but these errors were encountered: