Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6008
Closed
Open
Issue created Apr 22, 2020 by Administrator@rootContributor

Regarding optional requestParams getting added to Body section during code generation

Created by: Uma19

Version of openapigenerator : v4.3.0 Issue description: In my openapi file if the entry of requestparams is like this /v1/request-type/list: post: tags: - request-type summary: Testing description: Testing operationId: addRequestTypeList requestBody: content: '/': schema: type: array items: $ref: '#/components/schemas/RequestType'

so the corresponding code that is getting gererated is like below export interface AddRequestTypeListRequest { requestType?: Array; } const response = await this.request({ path: /v1/request-type/list, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.requestType.map(RequestTypeToJSON), }); which gives error during compile time as (property) AddRequestTypeListRequest.requestType?: RequestType[] | undefined Object is possibly 'undefined'.

Ideally the body content should be created like this optional to resolve the above error body: requestParameters.requestType.?map(RequestTypeToJSON),

Also checked the github code for the same. Can we add this provision or is there any other way

https://github.com/OpenAPITools/openapi-generator/blob/v4.3.0/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache line no 255 line no 21

Can you help me to resolve this issue

Assignee
Assign to
Time tracking