quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

Freeform Map<String,String> configuration properties always marked as required #42505

Closed ppalaga closed 2 months ago

ppalaga commented 2 months ago

Describe the bug

We have a config property in Quarkus CXF defined as follows:

        @WssConfigurationConstant(key = "security.signature.properties", transformer = properties)
        @WithName("signature.properties")
        Map<String, String> signatureProperties();

Before the recent refactoring of quarkus-extension-processor, the metadata was produced with "optional": true in target/asciidoc/generated/config/all-configuration-roots-generated-doc/io.quarkiverse.cxf.ws.security.CxfWsSecurityConfig:

  {
    "configDocKey": {
      "type": "`Map<String,String>`",
      "key": "quarkus.cxf.client.\"client-name\".security.signature.properties",
      "additionalKeys": [],
      "configDoc": "The Crypto property configuration to use for signing, if `signature.crypto` is not set.\n\nExample\n\n[source,properties]\n----\n[prefix].signature.properties.\"org.apache.ws.security.crypto.provider\" =\norg.apache.ws.security.components.crypto.Merlin\n[prefix].signature.properties.\"org.apache.ws.security.crypto.merlin.keystore.password\" = password\n[prefix].signature.properties.\"org.apache.ws.security.crypto.merlin.file\" = certs/alice.jks\n----",
      "withinAMap": true,
      "defaultValue": "",
      "javaDocSiteLink": "",
      "docMapKey": "signature-properties",
      "configPhase": "RUN_TIME",
      "acceptedValues": null,
      "optional": true,
      "list": false,
      "passThroughMap": true,
      "withinAConfigGroup": true,
      "topLevelGrouping": "quarkus.cxf",
      "since": "2.5.0",
      "environmentVariable": "QUARKUS_CXF_CLIENT__CLIENT_NAME__SECURITY_SIGNATURE_PROPERTIES",
      "enum": false
    }
  },

After the refactoring, the target/quarkus-config-doc/quarkus-config-model.yaml file is produced without "optional": true:

  - !<io.quarkus.annotation.processor.documentation.config.model.ConfigProperty>
    sourceClass: "io.quarkiverse.cxf.ws.security.CxfWsSecurityConfig.ClientOrEndpointSecurityConfig"
    sourceName: "signatureProperties"
    path: "quarkus.cxf.client.\"client-name\".security.signature.properties.\"signature-properties\""
    type: "java.util.Map<java.lang.String,java.lang.String>"
    phase: "RUN_TIME"
    environmentVariable: "QUARKUS_CXF_CLIENT__CLIENT_NAME__SECURITY_SIGNATURE_PROPERTIES__SIGNATURE_PROPERTIES_"
    typeDescription: "Map<String,String>"
    map: true
    mapKey: "signature-properties"
    withinMap: true

Expected behavior

Freeform Map<String,String> configuration properties should be always considered optional - same like before the refactoring. Therefore "optional": true should be present in the metadata.

Actual behavior

"optional": true is missing in the metadata.

How to Reproduce?

Rebuild quarkus-agroal in Quarkus source tree and check quarkus.datasource.jdbc.additional-jdbc-properties in its target/quarkus-config-doc/quarkus-config-model.yaml.

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

quarkus-bot[bot] commented 2 months ago

/cc @radcortez (config)

ppalaga commented 2 months ago

I have an idea how to fix this

ppalaga commented 2 months ago

The same issue exists for quarkus.kafka.devservices.topic-partitions that is a Map<String,Integer>. Here is the old json:

{
    "configDocKey": {
      "type": "`Map<String,Integer>`",
      "key": ".topic-partitions",
      "additionalKeys": [],
      "configDoc": "The topic-partition pairs to create in the Dev Services Kafka broker. After the broker is started, given topics with partitions are created, skipping already existing topics. For example, `quarkus.kafka.devservices.topic-partitions.test=2` will create a topic named `test` with 2 partitions.\n\nThe topic creation will not try to re-partition existing topics with different number of partitions.",
      "withinAMap": true,
      "defaultValue": "",
      "javaDocSiteLink": "",
      "docMapKey": "topic-partitions",
      "configPhase": "BUILD_TIME",
      "acceptedValues": null,
      "optional": true,
      "list": false,
      "passThroughMap": true,
      "withinAConfigGroup": true,
      "topLevelGrouping": "",
      "since": null,
      "environmentVariable": "_TOPIC_PARTITIONS",
      "enum": false
    }
  },

So I am going to fix this for all maps whose value type is either String or some primitive type wrapper.