LinuxForHealth / FHIR

The LinuxForHealth FHIR® Server and related projects
https://linuxforhealth.github.io/FHIR
Apache License 2.0
330 stars 157 forks source link

Media.getContent().getData().getValue() javadoc isn't clear that it is decoding the Base64 #3699

Open henryhbk opened 2 years ago

henryhbk commented 2 years ago

The javadoc for Media.getContent().getData().getValue() reads that .getValue() will give you the "The actual value" which implies that without we get some random value that isn't the actual value?? I think a better phrase might be the "originally decoded data" or just the "decoded content" might be more obvious that it is doing the base64.decode(byte[]) for you (that was definitely not obvious at first glance)

lmsurpre commented 2 years ago

These Javadoc are generated from the actual spec artifacts. You can see "The actual value" is coming from the definition of this field in the specification (FHIR R4B):

        {
          "id" : "base64Binary.value",
          "path" : "base64Binary.value",
          "representation" : ["xmlAttr"],
          "short" : "Primitive value for base64Binary",
          "definition" : "The actual value",
          "min" : 0,
          "max" : "1",
          "base" : {
            "path" : "base64Binary.value",
            "min" : 0,
            "max" : "1"
          },
          "type" : [{
            "extension" : [{
              "url" : "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type",
              "valueUrl" : "base64Binary"
            },
            {
              "url" : "http://hl7.org/fhir/StructureDefinition/regex",
              "valueString" : "(\\s*([0-9a-zA-Z\\+/=]){4}\\s*)+"
            }],
            "code" : "http://hl7.org/fhirpath/System.String"
          }],
          "isModifier" : false,
          "isSummary" : false
        }

My suggestion: special-case this one datatype and append something like this to the javadoc:

The raw, unencoded bytes represented by this base64Binary