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

An operation is not implemented: Name Generated for inline objects of unions not yet supported. #90

Open
martinbonnin opened this issue Sep 29, 2024 · 2 comments

Comments

@martinbonnin
Copy link

Not 100% sure what's happening here. I think the following is valid?

openapi: 3.0.1
info:
  title: Hello World API
  version: '1.0'
paths:
  /hello-world:
    get:
      operationId: hello-world
      responses:
        '200':
          description: updated
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    properties:
                      id:
                        type: integer
                  - type: object
                    properties:
                      username:
                        type: string
@nomisRev
Copy link
Owner

nomisRev commented Oct 2, 2024

Hey @martinbonnin,

Okay, I see. Without having looked at the code, I think this might be just a branch missing somewhere in the code where I left a TODO. Reason being that there is no name defined for the allOf type here, so a name needs to be generated.

A generalised name generation could be:

sealed interface GetHelloWorldResponse
@JvmInline value class First(val id: Int): GetHelloWorldResponse
@JvmInline value class Second(val username: String): GetHelloWorldResponse

Much more desirable would be:

sealed interface GetHelloWorldResponse
@JvmInline value class Id(val id: Int): GetHelloWorldResponse
@JvmInline value class Username(val value: String): GetHelloWorldResponse

I'm open to building a special case into the (not yet overrideable) name generation part, to detect that if a name needs to be generated for an object with a single property, it can use the property name for name generation. In the case there is no conflict in the property names of the different subtypes of course.

Thank you for opening the issues 🙏

@martinbonnin
Copy link
Author

It's an allOf() though so my understanding is more that it should contain all properties?

@JvmInline value class GetHelloWorldResponse(val id: Int, val value: String)

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

No branches or pull requests

2 participants