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
  • #50
Closed
Open
Issue created May 15, 2018 by Administrator@rootContributor

DefaultGenerator: unusedSchemas contains too many schemas

Created by: jmini

Some model object are missing when the server is configured to consume both application/json and application/x-www-form-urlencoded.

With this example the model SomeObject is not generated:

swagger: '2.0'
info:
  title: Test
  description: Test API
  version: 1.0.0
host: some.example.com
basePath: /v1
schemes:
  - https
  - http
consumes:
  - application/json
  - application/x-www-form-urlencoded
produces:
  - application/json
paths:
  /testMe:
    post:
      tags:
        - db
      operationId: testMeOp
      parameters:
        - in: body
          name: body
          required: false
          schema:
            $ref: '#/definitions/SomeObject'
      responses:
        '200':
          description: Successful Operation
definitions:
  SomeObject:
    type: object
    properties:
      p1:
        type: string
      p2:
        type: integer
        format: int32

This is due to org.openapitools.codegen.utils.ModelUtils.getUnusedSchemas(OpenAPI) not working as expected.

I am not sure if the dual consumes definition is correct or not (it is derived from a spec send by a used), but we could also imagine an other case with 2 path. In one JSON is expected as request body, in the other an application/x-www-form-urlencoded request body. In this case, the schema is also used.

In my opinion the logic to compute the unused schema should be to compute all the used schema and subtract them from a set containing all schemas.

Assignee
Assign to
Time tracking