Closed sauterl closed 1 year ago
Sorry for late response, I didn't notice this issue.
@OpenApiByFields
?@OpenApiIgnore
@JacksonAnnotationsInside
@JsonIgnore
annotation class IgnoreInJacksonAndOpenApi
or with some custom handler in our scripting API.
No worries, and thanks for the reply.
No, we do not use @OpenApiByFields
.
I guess then this might be a bug:
We do have the following setup:
interface IMyLittleMoreThanPojo {
val propertyWeWantInTheApi: ISomeType
val propertyWeDontWant: IOtherType
}
data class ApiMyLittleMoreThanPojo(
override val propertyWeWantInTheApi = ApiSomeType()
) : IMyLittleMoreThanPojo {
@JsonIgnore
override lateinit var propertyWeDontWant: ApiOtherType
internal set
} :
This setup then results in the following OpenApi JSON:
"ApiMyLittleMoreThanPojo": {
"type": "object",
"additionalProperties": false,
"properties":{
"propertyWeWantInTheApi": {
"$ref":"#/components/schemas/ApiSomeType"
},
"propertyWeDontWant":{
"$ref":"#/components/schemas/ApiOtherType"
}
},
"required":["propertyWeWantInTheApi", "propertyWeDontWant"]
}
Due to our setup, we cannot use @OpenApiIgnore
, since propertyWeDontWant
is a member property with backing field -- it might be worthwhile to simply adjust @OpenApiIgnore
?
Oh, that's a property, not a field - I thought you're using Java, not Kotlin. You should annotate this with site target, like that:
@get:OpenApiIgnore
val propertyWeDontWant: IOtherType
Thanks for pointing this out! I wasn't aware of site targeted annotations and my apologies for not properly label this as a kotlin problem.
There's a nice plugin that can simplify this btw: #171
When using javalin, one way to handle serialization / deserialization could be done by Jackson and thus, properties that should be ignored are annotated with
@JsonIgnore
.Unfortunately, the openapi plugin corresponding annotation,
@OpenApiIgnore
is not applicable toFIELD
, as@JsonIgnore
is.My thoughts on this are as follows:
@OpenApiIgnore
is configured to not targetFIELD
s? And if not, could we expand the target list accordingly?@JsonIgnore
annotated elements?Thanks in advance!