Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] is not of type 'object' when #/ referencing #14317

Open
5 tasks done
wingsofovnia opened this issue Dec 22, 2022 · 1 comment
Open
5 tasks done

[BUG] is not of type 'object' when #/ referencing #14317

wingsofovnia opened this issue Dec 22, 2022 · 1 comment

Comments

@wingsofovnia
Copy link
Contributor

wingsofovnia commented Dec 22, 2022

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

I've been following the idea from OAI/OpenAPI-Specification#1590 (comment) to "override" required field.

MySchema.yaml

type: object
properties:
  foo: 
    type: integer
  bar:
    type: integer
required:
  - foo
  - bar

src/spec.yaml

patch:      
  summary: Update something
  requestBody:
    content:                                     
      application/json:
        schema:
          type: object
          properties:
            $ref: ../components/schemas/MySchema.yaml#/properties

The generator fails on:

-attribute paths.'.....requestBody.content.'application/json'.schema.properties is not of type `object`

It feels like validation ignores #/properties. bundling with -dereference however recognizes the reference correctly and works fine but applying generator on a bundled & dereferenced spec is a so-so workaround because it loses the filename context and generated DTOs have very clunky naming.

I also tried to walk around this by having:
MySchemaProps.yaml

foo: 
    type: integer
  bar:
    type: integer

MySchema.yaml

type: object
properties:
  $ref: './MySchemaProps.yaml'

to avoid #/ ref, but I get

Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `io.swagger.v3.oas.models.media.ObjectSchema` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('./MySchemaProps.yaml')
 at [Source: UNKNOWN; byte offset: #UNKNOWN]

Again, bundling with -dereference works fine on this too but not generator.

Neither works an example from spec: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#models-with-composition
all allOf props in Kotlin generator goes to some weird allOf-prefixed data class and there is no DTO with all of the properties in one place.

openapi-generator version

6.2.1

Related issues/PRs
@simonwfarrow
Copy link

Hi - is there a fix to this? The workaround of dereference'ing did not work for me. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants