Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4aa45e6

Browse files
[Bug] NPE in KotlinDeprecatedPropertyCustomizer - resolvedSchema is null. Fixes #3121
1 parent 85ecc01 commit 4aa45e6

File tree

3 files changed

+109
-1
lines changed

3 files changed

+109
-1
lines changed

‎springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/KotlinDeprecatedPropertyCustomizer.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class KotlinDeprecatedPropertyCustomizer(
6464
prop.hasAnnotation<Deprecated>()
6565
if (deprecatedAnnotation != null) {
6666
val fieldName = prop.name
67-
if (resolvedSchema.`$ref` != null) {
67+
if (resolvedSchema!=null&& resolvedSchema.`$ref` != null) {
6868
val schema =
6969
context.getDefinedModels()[resolvedSchema.`$ref`.substring(
7070
Components.COMPONENTS_SCHEMAS_REF.length
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 the original author or authors.
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * https://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package test.org.springdoc.api.v31.app22
20+
21+
import com.fasterxml.jackson.annotation.JsonUnwrapped
22+
import io.swagger.v3.oas.annotations.Parameter
23+
import io.swagger.v3.oas.annotations.enums.Explode
24+
import io.swagger.v3.oas.annotations.media.ArraySchema
25+
import io.swagger.v3.oas.annotations.media.Schema
26+
import jakarta.validation.Valid
27+
import org.springdoc.core.annotations.ParameterObject
28+
import org.springframework.boot.autoconfigure.SpringBootApplication
29+
import org.springframework.http.ResponseEntity
30+
import org.springframework.web.bind.annotation.GetMapping
31+
import org.springframework.web.bind.annotation.RequestMapping
32+
import org.springframework.web.bind.annotation.RestController
33+
import test.org.springdoc.api.v31.AbstractKotlinSpringDocMVCTest
34+
35+
class SpringDocApp22Test : AbstractKotlinSpringDocMVCTest() {
36+
@SpringBootApplication
37+
class DemoApplication
38+
}
39+
40+
41+
42+
@RestController
43+
@RequestMapping("/test")
44+
@SpringBootApplication
45+
class DemoApp {
46+
@GetMapping
47+
fun getTestData(): Foo = Foo(bar = Bar(baz = "test"))
48+
}
49+
50+
data class Foo(
51+
@field:JsonUnwrapped
52+
val bar: Bar,
53+
)
54+
55+
data class Bar(
56+
@Deprecated("This is deprecated")
57+
val baz: String,
58+
)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"openapi": "3.1.0",
3+
"info": {
4+
"title": "OpenAPI definition",
5+
"version": "v0"
6+
},
7+
"servers": [
8+
{
9+
"url": "http://localhost",
10+
"description": "Generated server url"
11+
}
12+
],
13+
"paths": {
14+
"/test": {
15+
"get": {
16+
"tags": [
17+
"demo-app"
18+
],
19+
"operationId": "getTestData",
20+
"responses": {
21+
"200": {
22+
"description": "OK",
23+
"content": {
24+
"*/*": {
25+
"schema": {
26+
"$ref": "#/components/schemas/Foo"
27+
}
28+
}
29+
}
30+
}
31+
}
32+
}
33+
}
34+
},
35+
"components": {
36+
"schemas": {
37+
"Foo": {
38+
"type": "object",
39+
"properties": {
40+
"baz": {
41+
"type": "string"
42+
}
43+
},
44+
"required": [
45+
"baz"
46+
]
47+
}
48+
}
49+
}
50+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /