Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Generator cannot handle empty schema #92

Closed
aburmeis opened this issue Apr 13, 2022 · 4 comments
Closed

Generator cannot handle empty schema #92

aburmeis opened this issue Apr 13, 2022 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@aburmeis
Copy link

aburmeis commented Apr 13, 2022

I have a read only part of an API where the content has no schema. At this point a Javascript anyor Java Object would be the appropriate representation. Looking for the OpenApi specification for that, an empty schema seems to be the right definition (see SO https://stackoverflow.com/a/43328994/12890):

components:
  schemas:
    AnyValue: {}

Doing so this type is not generated nor replaced by Object, it is simply not handled. Even an explicit type mapping (to java.lang.Object e.g.) is ignored so the generated code is not compiling.

The only work around I found looks like this (I don't need array):

AnyValue:
  anyOf:
    - type: object
    - type: string
    - type: number
    - type: integer
    - type: boolean

and an explicit type mapping

map:
  types:
    - type: AnyValue => java.lang.Object

I am using openapi-processor-maven-plugin version 2021.1 with openapi-processor-spring version 2022.2.

@hauner
Copy link
Member

hauner commented Apr 14, 2022

The empty schema is a weak spot. I have to look at it.

That the mapping does not work is unexpected. I wonder what's going wrong there.

hauner added a commit that referenced this issue Apr 18, 2022
hauner added a commit that referenced this issue Apr 18, 2022
hauner added a commit that referenced this issue Apr 18, 2022
hauner added a commit that referenced this issue Apr 18, 2022
@hauner
Copy link
Member

hauner commented Apr 18, 2022

it is now possible and necessary to add a type mapping for this case.

That the processor does not generate code for the empty schema is caused by another case that must not generate a class.

Nothing I want to touch right now, so I just added the missing mapping possibility for now.

@hauner hauner added this to the 2022.4 milestone Apr 18, 2022
@hauner
Copy link
Member

hauner commented Apr 19, 2022

released in io.openapiprocessor:openapi-processor-spring:2022.3

@hauner hauner closed this as completed Apr 19, 2022
@hauner hauner added the bug Something isn't working label Apr 19, 2022
@aburmeis
Copy link
Author

Works now with 2022.3, thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants