-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(schemaFormat): support OpenAPI 3.0.1, 3.0.2, 3.0.3
- Loading branch information
Showing
23 changed files
with
2,586 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...ore/src/test/kotlin/com/asyncapi/v3/schema/multiformat/openapi/OpenAPIFormatSchemaTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.asyncapi.v3.schema.multiformat.openapi | ||
|
||
import com.asyncapi.v3.ClasspathUtils | ||
import com.asyncapi.v3.schema.multiformat.OpenAPIFormatSchema | ||
import com.fasterxml.jackson.annotation.JsonInclude | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory | ||
import org.junit.jupiter.api.Assertions | ||
|
||
abstract class OpenAPIFormatSchemaTest { | ||
|
||
private val objectMapper: ObjectMapper = ObjectMapper(YAMLFactory()) | ||
.setSerializationInclusion(JsonInclude.Include.NON_NULL) | ||
.findAndRegisterModules() | ||
|
||
fun compareSchemas( | ||
openAPIFormatSchemaToCompareWithFilePath: String, | ||
schemaToCheck: OpenAPIFormatSchema | ||
) { | ||
val schemaAsJson = ClasspathUtils.readAsString(openAPIFormatSchemaToCompareWithFilePath) | ||
val schema = objectMapper.readValue(schemaAsJson, OpenAPIFormatSchema::class.java) | ||
|
||
Assertions.assertEquals(schema, schemaToCheck) | ||
} | ||
|
||
abstract fun parseJson( | ||
openAPIFormatSchemaToCompareWithFilePath: String, | ||
openAPIFormatSchema: OpenAPIFormatSchema | ||
) | ||
|
||
abstract fun parseYaml( | ||
openAPIFormatSchemaToCompareWithFilePath: String, | ||
openAPIFormatSchema: OpenAPIFormatSchema | ||
) | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
...c/test/kotlin/com/asyncapi/v3/schema/multiformat/openapi/OpenAPIFormatSchemaV3_0_0Test.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.asyncapi.v3.schema.multiformat.openapi | ||
|
||
import com.asyncapi.v3.schema.multiformat.OpenAPIFormatSchema | ||
import com.asyncapi.v3.schema.openapi.SchemaTest | ||
import org.junit.jupiter.api.extension.ExtensionContext | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.Arguments | ||
import org.junit.jupiter.params.provider.ArgumentsProvider | ||
import org.junit.jupiter.params.provider.ArgumentsSource | ||
import java.util.stream.Stream | ||
|
||
abstract class OpenAPIFormatSchemaV3_0_0Test: OpenAPIFormatSchemaTest() { | ||
|
||
@ArgumentsSource(JsonFormat::class) | ||
@ParameterizedTest(name = "Read: {0}") | ||
override fun parseJson( | ||
openAPIFormatSchemaToCompareWithFilePath: String, | ||
openAPIFormatSchema: OpenAPIFormatSchema | ||
) { | ||
compareSchemas(openAPIFormatSchemaToCompareWithFilePath, openAPIFormatSchema) | ||
} | ||
|
||
@ArgumentsSource(YamlFormat::class) | ||
@ParameterizedTest(name = "Read: {0}") | ||
override fun parseYaml( | ||
openAPIFormatSchemaToCompareWithFilePath: String, | ||
openAPIFormatSchema: OpenAPIFormatSchema | ||
) { | ||
compareSchemas(openAPIFormatSchemaToCompareWithFilePath, openAPIFormatSchema) | ||
} | ||
|
||
class JsonFormat: ArgumentsProvider { | ||
|
||
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { | ||
return Stream.of( | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.0/vnd.oai.openapi/schema.json", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi;version=3.0.0", SchemaTest().openAPISchema()) | ||
), | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.0/vnd.oai.openapi+json/schema.json", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi+json;version=3.0.0", SchemaTest().openAPISchema()) | ||
) | ||
) | ||
} | ||
|
||
} | ||
|
||
class YamlFormat: ArgumentsProvider { | ||
|
||
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { | ||
return Stream.of( | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.0/vnd.oai.openapi/schema.yaml", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi;version=3.0.0", SchemaTest().openAPISchema()) | ||
), | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.0/vnd.oai.openapi+yaml/schema.yaml", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi+yaml;version=3.0.0", SchemaTest().openAPISchema()) | ||
) | ||
) | ||
} | ||
|
||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
...c/test/kotlin/com/asyncapi/v3/schema/multiformat/openapi/OpenAPIFormatSchemaV3_0_1Test.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.asyncapi.v3.schema.multiformat.openapi | ||
|
||
import com.asyncapi.v3.schema.multiformat.OpenAPIFormatSchema | ||
import com.asyncapi.v3.schema.multiformat.openapi.OpenAPIFormatSchemaV3_0_0Test.JsonFormat | ||
import com.asyncapi.v3.schema.multiformat.openapi.OpenAPIFormatSchemaV3_0_0Test.YamlFormat | ||
import com.asyncapi.v3.schema.openapi.SchemaTest | ||
import org.junit.jupiter.api.extension.ExtensionContext | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.Arguments | ||
import org.junit.jupiter.params.provider.ArgumentsProvider | ||
import org.junit.jupiter.params.provider.ArgumentsSource | ||
import java.util.stream.Stream | ||
|
||
abstract class OpenAPIFormatSchemaV3_0_1Test: OpenAPIFormatSchemaTest() { | ||
|
||
@ArgumentsSource(JsonFormat::class) | ||
@ParameterizedTest(name = "Read: {0}") | ||
override fun parseJson( | ||
openAPIFormatSchemaToCompareWithFilePath: String, | ||
openAPIFormatSchema: OpenAPIFormatSchema | ||
) { | ||
compareSchemas(openAPIFormatSchemaToCompareWithFilePath, openAPIFormatSchema) | ||
} | ||
|
||
@ArgumentsSource(YamlFormat::class) | ||
@ParameterizedTest(name = "Read: {0}") | ||
override fun parseYaml( | ||
openAPIFormatSchemaToCompareWithFilePath: String, | ||
openAPIFormatSchema: OpenAPIFormatSchema | ||
) { | ||
compareSchemas(openAPIFormatSchemaToCompareWithFilePath, openAPIFormatSchema) | ||
} | ||
|
||
class JsonFormat: ArgumentsProvider { | ||
|
||
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { | ||
return Stream.of( | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.1/vnd.oai.openapi/schema.json", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi;version=3.0.1", SchemaTest().openAPISchema()) | ||
), | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.1/vnd.oai.openapi+json/schema.json", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi+json;version=3.0.1", SchemaTest().openAPISchema()) | ||
) | ||
) | ||
} | ||
|
||
} | ||
|
||
class YamlFormat: ArgumentsProvider { | ||
|
||
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { | ||
return Stream.of( | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.1/vnd.oai.openapi/schema.yaml", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi;version=3.0.1", SchemaTest().openAPISchema()) | ||
), | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.1/vnd.oai.openapi+yaml/schema.yaml", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi+yaml;version=3.0.1", SchemaTest().openAPISchema()) | ||
) | ||
) | ||
} | ||
|
||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
...c/test/kotlin/com/asyncapi/v3/schema/multiformat/openapi/OpenAPIFormatSchemaV3_0_2Test.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.asyncapi.v3.schema.multiformat.openapi | ||
|
||
import com.asyncapi.v3.schema.multiformat.OpenAPIFormatSchema | ||
import com.asyncapi.v3.schema.multiformat.openapi.OpenAPIFormatSchemaV3_0_0Test.JsonFormat | ||
import com.asyncapi.v3.schema.multiformat.openapi.OpenAPIFormatSchemaV3_0_0Test.YamlFormat | ||
import com.asyncapi.v3.schema.openapi.SchemaTest | ||
import org.junit.jupiter.api.extension.ExtensionContext | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.Arguments | ||
import org.junit.jupiter.params.provider.ArgumentsProvider | ||
import org.junit.jupiter.params.provider.ArgumentsSource | ||
import java.util.stream.Stream | ||
|
||
abstract class OpenAPIFormatSchemaV3_0_2Test: OpenAPIFormatSchemaTest() { | ||
|
||
@ArgumentsSource(JsonFormat::class) | ||
@ParameterizedTest(name = "Read: {0}") | ||
override fun parseJson( | ||
openAPIFormatSchemaToCompareWithFilePath: String, | ||
openAPIFormatSchema: OpenAPIFormatSchema | ||
) { | ||
compareSchemas(openAPIFormatSchemaToCompareWithFilePath, openAPIFormatSchema) | ||
} | ||
|
||
@ArgumentsSource(YamlFormat::class) | ||
@ParameterizedTest(name = "Read: {0}") | ||
override fun parseYaml( | ||
openAPIFormatSchemaToCompareWithFilePath: String, | ||
openAPIFormatSchema: OpenAPIFormatSchema | ||
) { | ||
compareSchemas(openAPIFormatSchemaToCompareWithFilePath, openAPIFormatSchema) | ||
} | ||
|
||
class JsonFormat: ArgumentsProvider { | ||
|
||
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { | ||
return Stream.of( | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.2/vnd.oai.openapi/schema.json", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi;version=3.0.2", SchemaTest().openAPISchema()) | ||
), | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.2/vnd.oai.openapi+json/schema.json", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi+json;version=3.0.2", SchemaTest().openAPISchema()) | ||
) | ||
) | ||
} | ||
|
||
} | ||
|
||
class YamlFormat: ArgumentsProvider { | ||
|
||
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { | ||
return Stream.of( | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.2/vnd.oai.openapi/schema.yaml", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi;version=3.0.2", SchemaTest().openAPISchema()) | ||
), | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.2/vnd.oai.openapi+yaml/schema.yaml", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi+yaml;version=3.0.2", SchemaTest().openAPISchema()) | ||
) | ||
) | ||
} | ||
|
||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
...c/test/kotlin/com/asyncapi/v3/schema/multiformat/openapi/OpenAPIFormatSchemaV3_0_3Test.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.asyncapi.v3.schema.multiformat.openapi | ||
|
||
import com.asyncapi.v3.schema.multiformat.OpenAPIFormatSchema | ||
import com.asyncapi.v3.schema.multiformat.openapi.OpenAPIFormatSchemaV3_0_0Test.JsonFormat | ||
import com.asyncapi.v3.schema.multiformat.openapi.OpenAPIFormatSchemaV3_0_0Test.YamlFormat | ||
import com.asyncapi.v3.schema.openapi.SchemaTest | ||
import org.junit.jupiter.api.extension.ExtensionContext | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.Arguments | ||
import org.junit.jupiter.params.provider.ArgumentsProvider | ||
import org.junit.jupiter.params.provider.ArgumentsSource | ||
import java.util.stream.Stream | ||
|
||
abstract class OpenAPIFormatSchemaV3_0_3Test: OpenAPIFormatSchemaTest() { | ||
|
||
@ArgumentsSource(JsonFormat::class) | ||
@ParameterizedTest(name = "Read: {0}") | ||
override fun parseJson( | ||
openAPIFormatSchemaToCompareWithFilePath: String, | ||
openAPIFormatSchema: OpenAPIFormatSchema | ||
) { | ||
compareSchemas(openAPIFormatSchemaToCompareWithFilePath, openAPIFormatSchema) | ||
} | ||
|
||
@ArgumentsSource(YamlFormat::class) | ||
@ParameterizedTest(name = "Read: {0}") | ||
override fun parseYaml( | ||
openAPIFormatSchemaToCompareWithFilePath: String, | ||
openAPIFormatSchema: OpenAPIFormatSchema | ||
) { | ||
compareSchemas(openAPIFormatSchemaToCompareWithFilePath, openAPIFormatSchema) | ||
} | ||
|
||
class JsonFormat: ArgumentsProvider { | ||
|
||
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { | ||
return Stream.of( | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.3/vnd.oai.openapi/schema.json", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi;version=3.0.3", SchemaTest().openAPISchema()) | ||
), | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.3/vnd.oai.openapi+json/schema.json", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi+json;version=3.0.3", SchemaTest().openAPISchema()) | ||
) | ||
) | ||
} | ||
|
||
} | ||
|
||
class YamlFormat: ArgumentsProvider { | ||
|
||
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> { | ||
return Stream.of( | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.3/vnd.oai.openapi/schema.yaml", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi;version=3.0.3", SchemaTest().openAPISchema()) | ||
), | ||
Arguments.of("/json/v3/schema/multiformat/openapi/3.0.3/vnd.oai.openapi+yaml/schema.yaml", | ||
OpenAPIFormatSchema("application/vnd.oai.openapi+yaml;version=3.0.3", SchemaTest().openAPISchema()) | ||
) | ||
) | ||
} | ||
|
||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.