Skip to content

Commit 47f9ad4

Browse files
committed
springdoc 3.0 + boot 4.0 breaks native image support Fixes #3155
1 parent 41e80b4 commit 47f9ad4

4 files changed

Lines changed: 151 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
*
3+
* *
4+
* * *
5+
* * * *
6+
* * * * *
7+
* * * * * * Copyright 2019-2025 the original author or authors.
8+
* * * * * *
9+
* * * * * * Licensed under the Apache License, Version 2.0 (the "License");
10+
* * * * * * you may not use this file except in compliance with the License.
11+
* * * * * * You may obtain a copy of the License at
12+
* * * * * *
13+
* * * * * * https://www.apache.org/licenses/LICENSE-2.0
14+
* * * * * *
15+
* * * * * * Unless required by applicable law or agreed to in writing, software
16+
* * * * * * distributed under the License is distributed on an "AS IS" BASIS,
17+
* * * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* * * * * * See the License for the specific language governing permissions and
19+
* * * * * * limitations under the License.
20+
* * * * *
21+
* * * *
22+
* * *
23+
* *
24+
*
25+
*/
26+
package org.springdoc.webflux.core.configuration.hints;
27+
28+
import org.springframework.aot.hint.RuntimeHints;
29+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
30+
import org.springframework.aot.hint.TypeReference;
31+
import org.springframework.web.reactive.accept.DefaultApiVersionStrategy;
32+
import org.springframework.web.reactive.accept.HeaderApiVersionResolver;
33+
import org.springframework.web.reactive.accept.MediaTypeParamApiVersionResolver;
34+
import org.springframework.web.reactive.accept.PathApiVersionResolver;
35+
import org.springframework.web.reactive.accept.QueryApiVersionResolver;
36+
37+
/**
38+
* @author bnasslahsen
39+
*/
40+
public class SpringDocWebFluxHints implements RuntimeHintsRegistrar {
41+
42+
@Override
43+
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
44+
45+
hints.reflection().registerType(
46+
TypeReference.of(DefaultApiVersionStrategy.class),
47+
builder -> builder.withField("versionResolvers")
48+
);
49+
50+
hints.reflection().registerType(
51+
TypeReference.of(MediaTypeParamApiVersionResolver.class),
52+
builder -> builder
53+
.withField("compatibleMediaType")
54+
.withField("parameterName")
55+
);
56+
57+
hints.reflection().registerType(
58+
TypeReference.of(PathApiVersionResolver.class),
59+
builder -> builder.withField("pathSegmentIndex")
60+
);
61+
62+
hints.reflection().registerType(
63+
TypeReference.of(HeaderApiVersionResolver.class),
64+
builder -> builder.withField("headerName")
65+
);
66+
67+
hints.reflection().registerType(
68+
TypeReference.of(QueryApiVersionResolver.class),
69+
builder -> builder.withField("queryParamName")
70+
);
71+
}
72+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.springframework.aot.hint.RuntimeHintsRegistrar=\
2+
org.springdoc.webflux.core.configuration.hints.SpringDocWebFluxHints
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
*
3+
* *
4+
* * *
5+
* * * *
6+
* * * * *
7+
* * * * * * Copyright 2019-2025 the original author or authors.
8+
* * * * * *
9+
* * * * * * Licensed under the Apache License, Version 2.0 (the "License");
10+
* * * * * * you may not use this file except in compliance with the License.
11+
* * * * * * You may obtain a copy of the License at
12+
* * * * * *
13+
* * * * * * https://www.apache.org/licenses/LICENSE-2.0
14+
* * * * * *
15+
* * * * * * Unless required by applicable law or agreed to in writing, software
16+
* * * * * * distributed under the License is distributed on an "AS IS" BASIS,
17+
* * * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* * * * * * See the License for the specific language governing permissions and
19+
* * * * * * limitations under the License.
20+
* * * * *
21+
* * * *
22+
* * *
23+
* *
24+
*
25+
*/
26+
27+
package org.springdoc.webmvc.core.configuration.hints;
28+
29+
import org.springframework.aot.hint.RuntimeHints;
30+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
31+
import org.springframework.aot.hint.TypeReference;
32+
import org.springframework.web.accept.DefaultApiVersionStrategy;
33+
import org.springframework.web.accept.HeaderApiVersionResolver;
34+
import org.springframework.web.accept.MediaTypeParamApiVersionResolver;
35+
import org.springframework.web.accept.PathApiVersionResolver;
36+
import org.springframework.web.accept.QueryApiVersionResolver;
37+
38+
/**
39+
* The type Spring doc MVC hints
40+
*
41+
* @author bnasslahsen
42+
*/
43+
public class SpringDocMvcHints implements RuntimeHintsRegistrar {
44+
45+
@Override
46+
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
47+
hints.reflection().registerType(
48+
TypeReference.of(DefaultApiVersionStrategy.class),
49+
builder -> builder.withField("versionResolvers")
50+
);
51+
52+
hints.reflection().registerType(
53+
TypeReference.of(MediaTypeParamApiVersionResolver.class),
54+
builder -> builder
55+
.withField("compatibleMediaType")
56+
.withField("parameterName")
57+
);
58+
59+
hints.reflection().registerType(
60+
TypeReference.of(PathApiVersionResolver.class),
61+
builder -> builder.withField("pathSegmentIndex")
62+
);
63+
64+
hints.reflection().registerType(
65+
TypeReference.of(HeaderApiVersionResolver.class),
66+
builder -> builder.withField("headerName")
67+
);
68+
69+
hints.reflection().registerType(
70+
TypeReference.of(QueryApiVersionResolver.class),
71+
builder -> builder.withField("queryParamName")
72+
);
73+
}
74+
}
75+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.springframework.aot.hint.RuntimeHintsRegistrar=\
2+
org.springdoc.webmvc.core.configuration.hints.SpringDocMvcHints

0 commit comments

Comments
 (0)