openapi-generator: [DefaultCodegen] Possible missing model for request body for OAS 3.0

Description

Consider the following spec:

openapi: 3.0.0
info:
  title: Test
  version: 1.0.0
servers:
  - url: 'http://test/'
components:
  requestBodies:
    TestBodyInline:
      content:
        application/json:
          schema:
            type: object
            properties:
              test:
                type: string
paths:
  /test/ref/inline:
    post:
      summary: Test
      requestBody:
        $ref: '#/components/requestBodies/TestBodyInline'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: string

For this spec CodegenOperation::bodyParam.dataType equals to “object” and no codegen model is generated for request body. A bit lost why this is happenning because 3 other possible scenarios (inline body + inline schema, inline body + ref schema, ref body + ref schema) work perfectly well.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 9
  • Comments: 15 (13 by maintainers)

Commits related to this issue

Most upvoted comments

I just hit by this. still happened on 4.0.0.beta.

I’ve started having a look at restoring InlineModelResolver.java - see https://github.com/bjgill/openapi-generator/tree/InlineModelResolver.

I’m now out of time to work on this for now, however. Anyone else who wants to pick this up would be more than welcome.

OK - the following (v2) definition was fixed by #736 (thanks @antihax!):

  ObjectOfObjects:
    description: An object of objects
    type: object
    properties:
      foo:
        type: object
        properties:
          bar:
            type: string

However, the following still doesn’t seem to work (at least for rust-server):

  ArrayOfObjects:
    description: An array of objects
    type: array
    items:
      properties:
        filename:
          description: A non-required property
          type: string
        contents:
          description: A required property
          type: string
      required:
      - contents
      type: object