2

I am trying to generate an API client for Nestjs using this openapi definition. However openapi-generator-cli report lots of missing content fields, here are a few examples:

[[nestjs-generator] ./hapi-fhir-openapi.yaml]   -attribute paths.'/ExampleScenario'(get).parameters.[status].content is missing
[[nestjs-generator] ./hapi-fhir-openapi.yaml]   -attribute paths.'/MedicinalProductPharmaceutical'(get).parameters.[_filter].content is missing
[[nestjs-generator] ./hapi-fhir-openapi.yaml]   -attribute paths.'/Account/{id}/$diff'(get).parameters.[to].content is missing
[[nestjs-generator] ./hapi-fhir-openapi.yaml]   -attribute paths.'/Organization/{id}/$validate'(get).parameters.[resource].content is missing
[[nestjs-generator] ./hapi-fhir-openapi.yaml]   -attribute paths.'/VerificationResult'(get).parameters.[_id].content is missing
[[nestjs-generator] ./hapi-fhir-openapi.yaml]   -attribute paths.'/StructureMap/{id}/$diff'(get).parameters.[to].content is missing
[[nestjs-generator] ./hapi-fhir-openapi.yaml]   -attribute paths.'/AppointmentResponse'(get).parameters.[_id].content is missing
[[nestjs-generator] ./hapi-fhir-openapi.yaml]   -attribute paths.'/EffectEvidenceSynthesis'(get).parameters.[_tag].content is missing
[[nestjs-generator] ./hapi-fhir-openapi.yaml]   -attribute paths.'/ImmunizationRecommendation'(get).parameters.[_tag].content is missing
[[nestjs-generator] ./hapi-fhir-openapi.yaml]   -attribute paths.'/SearchParameter/{id}/$diff'(get).parameters.[from].content is missing

Here is the openapitools.json that I am using:

{
  "$schema": "/home/myname/.nvm/versions/node/v14.15.0/lib/node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "6.0.1",
    "generators": {
      "nestjs-generator": {
        "generatorName": "typescript-nestjs",
        "output": "./output",
        "inputSpec": "./hapi-fhir-openapi.yaml",
        "additionalProperties": {
          "npmName": "hapi-fhir-api",
          "nestVersion": "8.0.0"
        }
      }
    }
  }
}

I also tried using version 6.1.0 and 6.2.0 and other typescript generators, but the errors remain.

As Postman manages to correctly import all api paths correctly from the definition I don't understand why these content fields are mandatory in openapi-generator. Is there a way to ignore or skip missing fields?

dude
  • 79
  • 6
  • 2
    Do you have control over the input OpenAPI document? I'm not really sure why `content` is required for parameters, but if there is neither `content`, nor `schema` in the parameter objects, you will not generate reasonable typescript from this with anything, as the type of the parameters is unknown. Also neither of your operations have an `operationId`, without that it will be a nightmare to read whatever is being generated from this. – Balázs Édes Oct 14 '22 at 09:43
  • 2
    As @BalázsÉdes correctly noted, the OpenAPI definition is invalid because the parameters are missing the `schema` (i.e. data type). You'll see similar errors if your paste the definition into https://editor.swagger.io. You can try to fix the definition yourself and use your own copy, and/or report the problem to the authors of that OpenAPI definition. – Helen Oct 14 '22 at 09:52
  • Thanks for your quick replies. I reported the problem to the developers [here](https://github.com/hapifhir/hapi-fhir/issues/4137). – dude Oct 14 '22 at 13:53

0 Answers0