Closed MarcelBochtler closed 2 years ago
Would the intent to be to take in unstructured data?
Assuming that is the case, you should be able to annotate the object with @FreeFormObject
like so
data class FreeFormData(
@FreeFormObject
val data: JsonElement
)
Assuming that is the case, you should be able to annotate the object with
@FreeFormObject
like sodata class FreeFormData( @FreeFormObject val data: JsonElement )
Using that application is able to start up, and to create a valid openapi.json
. But the resulting example Response is wrong:
{
"data": {
...
}
}
While the endpoint just returns the plain JsonObject:
{
...
}
oh i see, so you want the complete payload to be totally unstructured? I don't believe that is supported. Likely, this will require allowing the FreeFormObject
annotation to be applied to classes along with properties, as well as performing a top level check when doing the core reflection to look for that annotation and short circuit if found.
So, you would be able to declare something like
@FreeFormObject
object AnythingGoesMan
@unredundant was this functionality removed / changed with version 3?
Unfortunately, I'm no longer able to generate the OpenAPI spec with an object using JsonElement as a value.
@FreeFormObject
no longer exists and I cannot find a substitute for it.
Oh yea it was... all annotations were removed in V3. I wasn't a fan of having to have to use annotations in order to get Kompendium to work (though I may still need to add them back to handle things like property constraints)
I think the best way to go here is to define a custom type https://bkbn.gitbook.io/kompendium/index-2/notarized_application#custom-types to represent the object you are trying to pass. You'll need to hand roll the JSON schema using the json schema interface, but that shouldn't be too bad for a totally free form object.
Could you give that a go and if it's too arduous, feel free to open a new issue and we will think through a way to make the experience nicer :)
Describe the bug When trying to document an Endpoint that responds a plain
JsonElement
, I'm no longer to start my application. It crashes with this exception:To Reproduce See: https://github.com/MarcelBochtler/kompendium/commit/045e40af73425d599ec37b4d50a20f6cb1ab8c67
Expected behavior The application is able to start and displays the serialized JsonElement in the OpenApi docs.