cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

Cannot find name 'file'. Did you mean 'File'? ts(2552) #272

Closed cristianscode closed 1 year ago

cristianscode commented 1 year ago

Hello, I am running into an issue that requires me to manually change all file types in all my services when I regenerate my services/models. When generated I get the snippet below, but Typescript does not like that because it the type should be "File", which is capitalized. I'm not sure if this is an issue in my Swagger.json or in my schema configuration. I've included the schema configuration which includes my swagger.json as well. Hope you can help!

addAttachmentFile$Plain(params?: {
    objectID?: number;
    fileName?: string;
    body?: {
    'file'?: file; // Cannot find name 'file'. Did you mean 'File'? ts(2552)
    }
  },
{
  "$schema": "./node_modules/ng-openapi-gen/ng-openapi-gen-schema.json",
  "input": "https://dev-api.cpsusa.com/SoriaAPI/API/swagger/v1/swagger.json",
  "output": "src/api",
  "ignoreUnusedModels": true,
  "defaultTag": "Api",
  "removeStaleFiles": true,
  "skipJsonSuffix": true,
  "modelIndex": false,
  "serviceIndex": false,
  "enumStyle": "upper",
  "module": true,
  "apiModule": true
}
luisfpg commented 1 year ago

The descriptor at https://dev-api.cpsusa.com/SoriaAPI/API/swagger/v1/swagger.json is invalid according to the OpenAPI specification. See https://spec.openapis.org/oas/v3.0.0#considerations-for-file-uploads For binary content, the specification must be: of type string and format either binary or base64. However, it is being specified as (note "type": "file"):

       "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "file",
                    "format": "binary"
                  }
                }
              },
              "encoding": {
                "file": {
                  "style": "form"
                }
              }
            }
          }
        }