Skip to content

Commit

Permalink
Moving to OpenAPI 3.1 as the default implementation for springdoc-ope…
Browse files Browse the repository at this point in the history
…napi. Fixes #2790
  • Loading branch information
bnasslahsen committed Jan 2, 2025
1 parent d003748 commit 9d7f6ae
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ private void trimIndentOperation(Operation operation) {
*/
protected void calculateWebhooks(OpenAPI calculatedOpenAPI, Locale locale) {
Webhooks[] webhooksAttr = openAPIService.getWebhooks();
if(ArrayUtils.isEmpty(webhooksAttr))
return;
var webhooks = Arrays.stream(webhooksAttr).map(Webhooks::value).flatMap(Arrays::stream).toArray(Webhook[]::new);
Arrays.stream(webhooks).forEach(webhook -> {
io.swagger.v3.oas.annotations.Operation apiOperation = webhook.operation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ public static class ApiDocs {
/**
* The OpenAPI version.
*/
private OpenApiVersion version;
private OpenApiVersion version = OpenApiVersion.OPENAPI_3_1;

/**
* Gets path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.reactive.server.WebTestClient;

@AutoConfigureWebTestClient(timeout = "3600000")
@ActiveProfiles("test")
@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" )
public abstract class AbstractCommonTest {

protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.reactive.server.WebTestClient;

@AutoConfigureWebTestClient(timeout = "3600000")
@ActiveProfiles("test")
@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" )
public abstract class AbstractCommonTest {

protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import test.org.springdoc.api.AbstractCommonTest;

import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MvcResult;

import static org.hamcrest.Matchers.is;
Expand All @@ -38,6 +39,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@SpringBootTest
@TestPropertySource(properties = { "springdoc.api-docs.version=openapi_3_0" })
public abstract class AbstractSpringDocV30Test extends AbstractCommonTest {

public static String className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
/**
* Tests deterministic creation of operationIds
*/
@SpringBootTest(properties = { SPRINGDOC_CACHE_DISABLED + "=true" })
@SpringBootTest(properties = { SPRINGDOC_CACHE_DISABLED + "=true", "springdoc.api-docs.version=openapi_3_0" })
public class SpringDocApp136Test extends AbstractCommonTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@SpringBootTest
@SpringBootTest(properties = { "springdoc.api-docs.version=openapi_3_0" })
public class SpringDocApp193Test extends AbstractCommonTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@

@SpringBootTest(properties = {
"springdoc.pre-loading-enabled=true",
"springdoc.pre-loading-locales=ja"
"springdoc.pre-loading-locales=ja",
"springdoc.api-docs.version=openapi_3_0"
})
public class SpringDocApp209Test extends AbstractCommonTest {
public static String className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@SpringBootTest
@TestPropertySource(properties = { "springdoc.api-docs.version=openapi_3_1" })
public abstract class AbstractSpringDocV31Test extends AbstractCommonTest {

public static String className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;

@AutoConfigureMockMvc
@ActiveProfiles("test")
@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" )
public abstract class AbstractCommonTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@AutoConfigureWebTestClient(timeout = "3600000")
@ActiveProfiles("test")
@TestPropertySource(properties = { "management.endpoints.enabled-by-default=false" })
@TestPropertySource(properties = { "management.endpoints.enabled-by-default=false" , "springdoc.api-docs.version=openapi_3_0" })
public abstract class AbstractCommonTest {

protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@AutoConfigureMockMvc
@ActiveProfiles("test")
@TestPropertySource(properties = { "management.endpoints.enabled-by-default=false" })
@TestPropertySource(properties = { "management.endpoints.enabled-by-default=false" , "springdoc.api-docs.version=openapi_3_0" })
public abstract class AbstractCommonTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
import java.nio.file.Paths;

import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.core.utils.Constants;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;

Expand All @@ -44,10 +43,9 @@
@ActiveProfiles("test")
@SpringBootTest
@AutoConfigureMockMvc
@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" )
public abstract class AbstractSpringDocTest {

protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractSpringDocTest.class);

public static String className;

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.reactive.server.WebTestClient;

@AutoConfigureWebTestClient(timeout = "3600000")
@ActiveProfiles("test")
@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" )
public abstract class AbstractCommonTest {

protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;

@AutoConfigureMockMvc
@ActiveProfiles("test")
@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" )
public abstract class AbstractCommonTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;

Expand All @@ -44,6 +45,7 @@
@ActiveProfiles("test")
@SpringBootTest
@AutoConfigureMockMvc
@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" )
public abstract class AbstractSpringDocTest {

protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractSpringDocTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;

Expand All @@ -48,6 +49,7 @@
@ActiveProfiles("test")
@SpringBootTest
@AutoConfigureMockMvc
@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" )
public abstract class AbstractSpringDocTest {

public static String className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;

Expand All @@ -47,6 +48,7 @@
@ActiveProfiles("test")
@SpringBootTest
@AutoConfigureMockMvc
@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" )
public abstract class AbstractSpringDocTest {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.reactive.server.EntityExchangeResult;
import org.springframework.test.web.reactive.server.WebTestClient;

import static org.skyscreamer.jsonassert.JSONAssert.assertEquals;

@WebFluxTest
@ActiveProfiles("test")
@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" )
public abstract class AbstractSpringDocTest {

protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractSpringDocTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.context.TestPropertySource
import org.springframework.test.web.reactive.server.WebTestClient
import java.nio.charset.StandardCharsets
import java.nio.file.Files
Expand All @@ -34,6 +35,7 @@ import java.nio.file.Paths
@WebFluxTest
@ActiveProfiles("test")
@AutoConfigureWebTestClient(timeout = "3600000")
@TestPropertySource(properties = ["springdoc.api-docs.version=openapi_3_0"])
abstract class AbstractKotlinSpringDocTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.ActiveProfiles
import org.springframework.test.context.TestPropertySource
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
import org.springframework.test.web.servlet.result.MockMvcResultMatchers
Expand All @@ -35,6 +36,7 @@ import java.nio.file.Paths
@SpringBootTest
@AutoConfigureMockMvc
@ActiveProfiles("test")
@TestPropertySource(properties = ["springdoc.api-docs.version=openapi_3_0"])
abstract class AbstractKotlinSpringDocMVCTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,15 @@ package test.org.springdoc.api.app13
import org.springdoc.core.properties.SpringDocConfigProperties
import org.springdoc.core.properties.SpringDocConfigProperties.ApiDocs.OpenApiVersion
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.test.context.TestPropertySource
import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest


@TestPropertySource(properties = ["springdoc.api-docs.version=openapi_3_1"])
class SpringDocApp13Test : AbstractKotlinSpringDocMVCTest() {

@SpringBootApplication
class DemoApplication {
@Bean
fun springDocConfigProperties():SpringDocConfigProperties{
val x= SpringDocConfigProperties()
x.apiDocs.version = OpenApiVersion.OPENAPI_3_1
return x
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;

Expand All @@ -45,6 +46,7 @@
@ActiveProfiles("test")
@SpringBootTest
@AutoConfigureMockMvc
@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" )
public abstract class AbstractSpringDocTest {

public static String className;
Expand Down

0 comments on commit 9d7f6ae

Please sign in to comment.