diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt index 012e6a613..75ac18dd4 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt @@ -181,6 +181,7 @@ internal class Integration(private val notebook: Notebook, private val options: "org.jetbrains.kotlinx:dataframe-jdbc:$version", "org.jetbrains.kotlinx:dataframe-arrow:$version", "org.jetbrains.kotlinx:dataframe-openapi:$version", + "org.jetbrains.kotlinx:dataframe-openapi-generator:$version", ) } diff --git a/dataframe-openapi-generator/build.gradle.kts b/dataframe-openapi-generator/build.gradle.kts new file mode 100644 index 000000000..b53a28397 --- /dev/null +++ b/dataframe-openapi-generator/build.gradle.kts @@ -0,0 +1,53 @@ +plugins { + with(libs.plugins) { + alias(kotlin.jvm) + alias(publisher) + alias(serialization) + alias(kover) + alias(ktlint) + alias(jupyter.api) + } +} + +group = "org.jetbrains.kotlinx" + +val jupyterApiTCRepo: String by project + +repositories { + mavenLocal() + mavenCentral() + maven(jupyterApiTCRepo) +} + +dependencies { + api(project(":core")) + api(project(":dataframe-openapi")) + + implementation(libs.sl4j) + implementation(libs.kotlinLogging) + implementation(libs.kotlin.reflect) + implementation(libs.kotlinpoet) + api(libs.swagger) { + // Fix for Android + exclude("jakarta.validation") + } + + testApi(project(":core")) + testImplementation(libs.junit) + testImplementation(libs.kotestAssertions) { + exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8") + } +} + +kotlinPublications { + publication { + publicationName = "dataframeOpenApi" + artifactId = project.name + description = "OpenAPI code generation support for Kotlin Dataframe" + packageName = artifactId + } +} + +kotlin { + explicitApi() +} diff --git a/dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/DefaultReadOpenApiMethod.kt b/dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/DefaultReadOpenApiMethod.kt similarity index 100% rename from dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/DefaultReadOpenApiMethod.kt rename to dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/DefaultReadOpenApiMethod.kt diff --git a/dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/OpenApi.kt b/dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/OpenApi.kt similarity index 100% rename from dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/OpenApi.kt rename to dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/OpenApi.kt diff --git a/dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/OpenApiMarker.kt b/dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/OpenApiMarker.kt similarity index 100% rename from dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/OpenApiMarker.kt rename to dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/OpenApiMarker.kt diff --git a/dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/OpenApiType.kt b/dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/OpenApiType.kt similarity index 100% rename from dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/OpenApiType.kt rename to dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/OpenApiType.kt diff --git a/dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/getMarker.kt b/dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/getMarker.kt new file mode 100644 index 000000000..d03289450 --- /dev/null +++ b/dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/getMarker.kt @@ -0,0 +1,30 @@ +package org.jetbrains.kotlinx.dataframe.io + +import org.jetbrains.kotlinx.dataframe.codeGen.FieldType +import org.jetbrains.kotlinx.dataframe.codeGen.Marker +import org.jetbrains.kotlinx.dataframe.codeGen.MarkerVisibility +import org.jetbrains.kotlinx.dataframe.codeGen.ValidFieldName + +internal fun AdditionalProperty.Companion.getMarker(typeArguments: List) = + Marker( + name = AdditionalProperty::class.qualifiedName!!, + isOpen = false, + fields = listOf( + generatedFieldOf( + fieldName = ValidFieldName.of(AdditionalProperty<*>::key.name), + columnName = AdditionalProperty<*>::key.name, + overrides = false, + fieldType = FieldType.ValueFieldType(String::class.qualifiedName!!), + ), + generatedFieldOf( + fieldName = ValidFieldName.of(AdditionalProperty<*>::`value`.name), + columnName = AdditionalProperty<*>::`value`.name, + overrides = false, + fieldType = FieldType.ValueFieldType(Any::class.qualifiedName!! + "?"), + ), + ), + superMarkers = emptyList(), + visibility = MarkerVisibility.EXPLICIT_PUBLIC, + typeParameters = emptyList(), + typeArguments = typeArguments, + ) diff --git a/dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/isOpenApi.kt b/dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/isOpenApi.kt similarity index 100% rename from dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/isOpenApi.kt rename to dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/isOpenApi.kt diff --git a/dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/readOpenapi.kt b/dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/readOpenapi.kt similarity index 100% rename from dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/readOpenapi.kt rename to dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/readOpenapi.kt diff --git a/dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/resultTypes.kt b/dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/resultTypes.kt similarity index 100% rename from dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/resultTypes.kt rename to dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/resultTypes.kt diff --git a/dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/utils.kt b/dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/utils.kt similarity index 100% rename from dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/utils.kt rename to dataframe-openapi-generator/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/utils.kt diff --git a/dataframe-openapi/src/main/resources/META-INF/services/org.jetbrains.kotlinx.dataframe.io.SupportedFormat b/dataframe-openapi-generator/src/main/resources/META-INF/services/org.jetbrains.kotlinx.dataframe.io.SupportedFormat similarity index 100% rename from dataframe-openapi/src/main/resources/META-INF/services/org.jetbrains.kotlinx.dataframe.io.SupportedFormat rename to dataframe-openapi-generator/src/main/resources/META-INF/services/org.jetbrains.kotlinx.dataframe.io.SupportedFormat diff --git a/dataframe-openapi/src/test/kotlin/OpenApiTests.kt b/dataframe-openapi-generator/src/test/kotlin/OpenApiTests.kt similarity index 100% rename from dataframe-openapi/src/test/kotlin/OpenApiTests.kt rename to dataframe-openapi-generator/src/test/kotlin/OpenApiTests.kt diff --git a/dataframe-openapi/src/test/resources/ApiGuruOpenApi.yaml b/dataframe-openapi-generator/src/test/resources/ApiGuruOpenApi.yaml similarity index 100% rename from dataframe-openapi/src/test/resources/ApiGuruOpenApi.yaml rename to dataframe-openapi-generator/src/test/resources/ApiGuruOpenApi.yaml diff --git a/dataframe-openapi/src/test/resources/ApiGuruSample.json b/dataframe-openapi-generator/src/test/resources/ApiGuruSample.json similarity index 100% rename from dataframe-openapi/src/test/resources/ApiGuruSample.json rename to dataframe-openapi-generator/src/test/resources/ApiGuruSample.json diff --git a/dataframe-openapi/src/test/resources/MlcGroupDataOpenApi.yaml b/dataframe-openapi-generator/src/test/resources/MlcGroupDataOpenApi.yaml similarity index 100% rename from dataframe-openapi/src/test/resources/MlcGroupDataOpenApi.yaml rename to dataframe-openapi-generator/src/test/resources/MlcGroupDataOpenApi.yaml diff --git a/dataframe-openapi/src/test/resources/apiGuruMetrics.json b/dataframe-openapi-generator/src/test/resources/apiGuruMetrics.json similarity index 100% rename from dataframe-openapi/src/test/resources/apiGuruMetrics.json rename to dataframe-openapi-generator/src/test/resources/apiGuruMetrics.json diff --git a/dataframe-openapi/src/test/resources/mlc_locations_with_people_data.json b/dataframe-openapi-generator/src/test/resources/mlc_locations_with_people_data.json similarity index 100% rename from dataframe-openapi/src/test/resources/mlc_locations_with_people_data.json rename to dataframe-openapi-generator/src/test/resources/mlc_locations_with_people_data.json diff --git a/dataframe-openapi/src/test/resources/mlc_people_with_location_data.json b/dataframe-openapi-generator/src/test/resources/mlc_people_with_location_data.json similarity index 100% rename from dataframe-openapi/src/test/resources/mlc_people_with_location_data.json rename to dataframe-openapi-generator/src/test/resources/mlc_people_with_location_data.json diff --git a/dataframe-openapi/src/test/resources/openapi_advanced_data.json b/dataframe-openapi-generator/src/test/resources/openapi_advanced_data.json similarity index 100% rename from dataframe-openapi/src/test/resources/openapi_advanced_data.json rename to dataframe-openapi-generator/src/test/resources/openapi_advanced_data.json diff --git a/dataframe-openapi/src/test/resources/openapi_advanced_data2.json b/dataframe-openapi-generator/src/test/resources/openapi_advanced_data2.json similarity index 100% rename from dataframe-openapi/src/test/resources/openapi_advanced_data2.json rename to dataframe-openapi-generator/src/test/resources/openapi_advanced_data2.json diff --git a/dataframe-openapi/src/test/resources/openapi_advanced_data3.json b/dataframe-openapi-generator/src/test/resources/openapi_advanced_data3.json similarity index 100% rename from dataframe-openapi/src/test/resources/openapi_advanced_data3.json rename to dataframe-openapi-generator/src/test/resources/openapi_advanced_data3.json diff --git a/dataframe-openapi/src/test/resources/openapi_advanced_example.yaml b/dataframe-openapi-generator/src/test/resources/openapi_advanced_example.yaml similarity index 100% rename from dataframe-openapi/src/test/resources/openapi_advanced_example.yaml rename to dataframe-openapi-generator/src/test/resources/openapi_advanced_example.yaml diff --git a/dataframe-openapi/src/test/resources/petstore.json b/dataframe-openapi-generator/src/test/resources/petstore.json similarity index 100% rename from dataframe-openapi/src/test/resources/petstore.json rename to dataframe-openapi-generator/src/test/resources/petstore.json diff --git a/dataframe-openapi/src/test/resources/petstore.yaml b/dataframe-openapi-generator/src/test/resources/petstore.yaml similarity index 100% rename from dataframe-openapi/src/test/resources/petstore.yaml rename to dataframe-openapi-generator/src/test/resources/petstore.yaml diff --git a/dataframe-openapi/src/test/resources/petstore_advanced.json b/dataframe-openapi-generator/src/test/resources/petstore_advanced.json similarity index 100% rename from dataframe-openapi/src/test/resources/petstore_advanced.json rename to dataframe-openapi-generator/src/test/resources/petstore_advanced.json diff --git a/dataframe-openapi/src/test/resources/some_advanced_failing_orders.json b/dataframe-openapi-generator/src/test/resources/some_advanced_failing_orders.json similarity index 100% rename from dataframe-openapi/src/test/resources/some_advanced_failing_orders.json rename to dataframe-openapi-generator/src/test/resources/some_advanced_failing_orders.json diff --git a/dataframe-openapi/src/test/resources/some_advanced_orders.json b/dataframe-openapi-generator/src/test/resources/some_advanced_orders.json similarity index 100% rename from dataframe-openapi/src/test/resources/some_advanced_orders.json rename to dataframe-openapi-generator/src/test/resources/some_advanced_orders.json diff --git a/dataframe-openapi/src/test/resources/some_advanced_pets.json b/dataframe-openapi-generator/src/test/resources/some_advanced_pets.json similarity index 100% rename from dataframe-openapi/src/test/resources/some_advanced_pets.json rename to dataframe-openapi-generator/src/test/resources/some_advanced_pets.json diff --git a/dataframe-openapi/build.gradle.kts b/dataframe-openapi/build.gradle.kts index 5b92ed5b4..2ca092c93 100644 --- a/dataframe-openapi/build.gradle.kts +++ b/dataframe-openapi/build.gradle.kts @@ -1,41 +1,18 @@ plugins { - with(libs.plugins) { - alias(kotlin.jvm) - alias(publisher) - alias(serialization) - alias(kover) - alias(ktlint) - alias(jupyter.api) - } + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.ktlint) + alias(libs.plugins.publisher) + alias(libs.plugins.jupyter.api) } group = "org.jetbrains.kotlinx" -val jupyterApiTCRepo: String by project - repositories { - mavenLocal() mavenCentral() - maven(jupyterApiTCRepo) } dependencies { api(project(":core")) - - implementation(libs.sl4j) - implementation(libs.kotlinLogging) - implementation(libs.kotlin.reflect) - implementation(libs.kotlinpoet) - api(libs.swagger) { - // Fix for Android - exclude("jakarta.validation") - } - - testApi(project(":core")) - testImplementation(libs.junit) - testImplementation(libs.kotestAssertions) { - exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8") - } } kotlinPublications { diff --git a/dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/AdditionalProperty.kt b/dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/AdditionalProperty.kt index 020f23df1..297c57c01 100644 --- a/dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/AdditionalProperty.kt +++ b/dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/AdditionalProperty.kt @@ -2,10 +2,6 @@ package org.jetbrains.kotlinx.dataframe.io import org.jetbrains.kotlinx.dataframe.annotations.DataSchema import org.jetbrains.kotlinx.dataframe.api.KeyValueProperty -import org.jetbrains.kotlinx.dataframe.codeGen.FieldType -import org.jetbrains.kotlinx.dataframe.codeGen.Marker -import org.jetbrains.kotlinx.dataframe.codeGen.MarkerVisibility -import org.jetbrains.kotlinx.dataframe.codeGen.ValidFieldName /** * A [DataSchema] interface can implement this if it represents a map-like data schema (so key: value). @@ -19,29 +15,5 @@ public interface AdditionalProperty : KeyValueProperty { /** Value of the property. */ override val value: T - public companion object { - internal fun getMarker(typeArguments: List) = - Marker( - name = AdditionalProperty::class.qualifiedName!!, - isOpen = false, - fields = listOf( - generatedFieldOf( - fieldName = ValidFieldName.of(AdditionalProperty<*>::key.name), - columnName = AdditionalProperty<*>::key.name, - overrides = false, - fieldType = FieldType.ValueFieldType(String::class.qualifiedName!!), - ), - generatedFieldOf( - fieldName = ValidFieldName.of(AdditionalProperty<*>::`value`.name), - columnName = AdditionalProperty<*>::`value`.name, - overrides = false, - fieldType = FieldType.ValueFieldType(Any::class.qualifiedName!! + "?"), - ), - ), - superMarkers = emptyList(), - visibility = MarkerVisibility.EXPLICIT_PUBLIC, - typeParameters = emptyList(), - typeArguments = typeArguments, - ) - } + public companion object } diff --git a/docs/StardustDocs/topics/gettingStartedGradleAdvanced.md b/docs/StardustDocs/topics/gettingStartedGradleAdvanced.md index 3afeab715..e527d2dc1 100644 --- a/docs/StardustDocs/topics/gettingStartedGradleAdvanced.md +++ b/docs/StardustDocs/topics/gettingStartedGradleAdvanced.md @@ -128,6 +128,11 @@ dependencies { implementation("org.jetbrains.kotlinx:dataframe-jdbc:%dataFrameVersion%") implementation("org.jetbrains.kotlinx:dataframe-arrow:%dataFrameVersion%") implementation("org.jetbrains.kotlinx:dataframe-openapi:%dataFrameVersion%") + + // This artifact is only needed to directly call functions that generate @DataSchema code from OpenAPI specifications + // It's used by Gradle and KSP plugins internally. + // Your project needs dataframe-openapi to use generated code + implementation("org.jetbrains.kotlinx:dataframe-openapi-generator:%dataFrameVersion%") } ``` @@ -144,6 +149,7 @@ dependencies { implementation 'org.jetbrains.kotlinx:dataframe-jdbc:%dataFrameVersion%' implementation 'org.jetbrains.kotlinx:dataframe-arrow:%dataFrameVersion%' implementation 'org.jetbrains.kotlinx:dataframe-openapi:%dataFrameVersion%' + implementation 'org.jetbrains.kotlinx:dataframe-openapi-generator:%dataFrameVersion%' } ``` diff --git a/plugins/dataframe-gradle-plugin/build.gradle.kts b/plugins/dataframe-gradle-plugin/build.gradle.kts index 32723a3d1..aaa0bd45c 100644 --- a/plugins/dataframe-gradle-plugin/build.gradle.kts +++ b/plugins/dataframe-gradle-plugin/build.gradle.kts @@ -20,7 +20,7 @@ dependencies { api(libs.kotlin.reflect) implementation(project(":core")) implementation(project(":dataframe-arrow")) - implementation(project(":dataframe-openapi")) + implementation(project(":dataframe-openapi-generator")) implementation(project(":dataframe-excel")) implementation(project(":dataframe-jdbc")) @@ -116,12 +116,13 @@ val integrationTestTask = task("integrationTest") { dependsOn(":dataframe-arrow:publishToMavenLocal") dependsOn(":dataframe-excel:publishToMavenLocal") dependsOn(":dataframe-jdbc:publishToMavenLocal") + dependsOn(":dataframe-openapi-generator:publishToMavenLocal") dependsOn(":dataframe-openapi:publishToMavenLocal") dependsOn(":publishApiPublicationToMavenLocal") dependsOn(":dataframe-arrow:publishDataframeArrowPublicationToMavenLocal") dependsOn(":dataframe-excel:publishDataframeExcelPublicationToMavenLocal") dependsOn(":dataframe-jdbc:publishDataframeJDBCPublicationToMavenLocal") - dependsOn(":dataframe-openapi:publishDataframeOpenApiPublicationToMavenLocal") + dependsOn(":dataframe-openapi-generator:publishDataframeOpenApiPublicationToMavenLocal") dependsOn(":plugins:symbol-processor:publishMavenPublicationToMavenLocal") dependsOn(":core:publishCorePublicationToMavenLocal") description = "Runs integration tests." diff --git a/plugins/symbol-processor/build.gradle.kts b/plugins/symbol-processor/build.gradle.kts index 85a33f7c7..e2f68dacf 100644 --- a/plugins/symbol-processor/build.gradle.kts +++ b/plugins/symbol-processor/build.gradle.kts @@ -20,7 +20,7 @@ group = "org.jetbrains.kotlinx.dataframe" dependencies { implementation(project(":core")) implementation(project(":dataframe-arrow")) - implementation(project(":dataframe-openapi")) + implementation(project(":dataframe-openapi-generator")) implementation(project(":dataframe-excel")) implementation(project(":dataframe-jdbc")) implementation(libs.ksp.api) diff --git a/plugins/symbol-processor/src/test/kotlin/org/jetbrains/dataframe/ksp/DataFrameSymbolProcessorTest.kt b/plugins/symbol-processor/src/test/kotlin/org/jetbrains/dataframe/ksp/DataFrameSymbolProcessorTest.kt index fd95e264d..39b25fe29 100644 --- a/plugins/symbol-processor/src/test/kotlin/org/jetbrains/dataframe/ksp/DataFrameSymbolProcessorTest.kt +++ b/plugins/symbol-processor/src/test/kotlin/org/jetbrains/dataframe/ksp/DataFrameSymbolProcessorTest.kt @@ -1153,7 +1153,7 @@ class DataFrameSymbolProcessorTest { } } - private val petstoreYaml = File("../../dataframe-openapi/src/test/resources/petstore.yaml") + private val petstoreYaml = File("../../dataframe-openapi-generator/src/test/resources/petstore.yaml") @Test fun `openApi yaml test`(): Unit = @@ -1238,7 +1238,7 @@ class DataFrameSymbolProcessorTest { } } - private val apiGuruMetricsJson = File("../../dataframe-openapi/src/test/resources/apiGuruMetrics.json") + private val apiGuruMetricsJson = File("../../dataframe-openapi-generator/src/test/resources/apiGuruMetrics.json") @Test fun `non openApi json test 2`(): Unit = @@ -1275,7 +1275,7 @@ class DataFrameSymbolProcessorTest { } } - private val petstoreJson = File("../../dataframe-openapi/src/test/resources/petstore.json") + private val petstoreJson = File("../../dataframe-openapi-generator/src/test/resources/petstore.json") @Test fun `openApi json test`(): Unit = diff --git a/settings.gradle.kts b/settings.gradle.kts index 43ed0bd81..fc1e0ebab 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -41,3 +41,4 @@ plugins { } include("dataframe-excel") include("core") +include("dataframe-openapi-generator")