Skip to content

Commit

Permalink
move to schema-kenerator 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SMILEY4 committed May 20, 2024
1 parent 11b2934 commit 54c8c3a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kotlin.code.style=official
# project id
projectGroupId=io.github.smiley4
projectArtifactIdBase=ktor-swagger-ui
projectVersion=3.0.0-beta1
projectVersion=3.0.0-beta2

# publishing information
projectNameBase=Ktor Swagger UI
Expand All @@ -19,7 +19,7 @@ projectDeveloperUrl=https://github.com/SMILEY4
versionKtor=2.3.11
versionSwaggerUI=5.9.0
versionSwaggerParser=2.1.19
versionSchemaKenerator=0.1.1
versionSchemaKenerator=0.2.0
versionKotlinLogging=3.0.5
versionKotest=5.8.0
versionKotlinTest=1.8.21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SchemaContextImpl(private val schemaConfig: SchemaConfigData) : SchemaCont
val schema = collapseRootRef(generateSchema(typeDescriptor))
componentSchemas[schemaId] = schema.swagger
schema.componentSchemas.forEach { (k, v) ->
componentSchemas[k.full()] = v
componentSchemas[k] = v
}
}
}
Expand All @@ -37,7 +37,7 @@ class SchemaContextImpl(private val schemaConfig: SchemaConfigData) : SchemaCont
if (schema.swagger.`$ref` == null) {
return schema
} else {
val referencedSchemaId = TypeId.parse(schema.swagger.`$ref`!!.replace("#/components/schemas/", ""))
val referencedSchemaId = schema.swagger.`$ref`!!.replace("#/components/schemas/", "")
val referencedSchema = schema.componentSchemas[referencedSchemaId]!!
return CompiledSwaggerSchema(
typeData = schema.typeData,
Expand All @@ -54,7 +54,7 @@ class SchemaContextImpl(private val schemaConfig: SchemaConfigData) : SchemaCont
val schema = generateSchema(typeDescriptor)
rootSchemas[typeDescriptor] = schema.swagger
schema.componentSchemas.forEach { (k, v) ->
componentSchemas[k.full()] = v
componentSchemas[k] = v
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ class ValueExampleDescriptor(
class RefExampleDescriptor(name: String, val refName: String) : ExampleDescriptor(name)

class SwaggerExampleDescriptor(name: String, val example: Example) : ExampleDescriptor(name)


Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ fun anyOf(vararg types: TypeDescriptor) = AnyOfTypeDescriptor(types.toList())
fun anyOf(types: Collection<TypeDescriptor>) = AnyOfTypeDescriptor(types.toList())

fun anyOf(vararg types: Schema<*>) = AnyOfTypeDescriptor(types.map { SwaggerTypeDescriptor(it) })
@JvmName("anyOfSwagger")
fun anyOf(types: Collection<Schema<*>>) = AnyOfTypeDescriptor(types.map { SwaggerTypeDescriptor(it) })

fun anyOf(vararg types: KType) = AnyOfTypeDescriptor(types.map { KTypeDescriptor(it) })
@JvmName("anyOfKType")
fun anyOf(types: Collection<KType>) = AnyOfTypeDescriptor(types.map { KTypeDescriptor(it) })
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class ValueExampleDescriptorDsl {
*/
var description: String? = null

}
}
7 changes: 4 additions & 3 deletions todo.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
todo:

- keep up to date with schema-kenerator
- keep up to date with schema-kenerator features
- simplify dsl for schemas (TypeDescriptors) ✅
- utility methods for adding different TypeDescriptors ✅
- dsl for array, anyof, ref, empty, ... ✅
- simplify dsl for examples (ExampleDescriptors) ✅
- add rootHostPath to operations (see 2.10.0)
- post build hook (?)
- add rootHostPath to operations (see 2.10.0) (is this required? -> see servers)
- post build hook (check if already exists?)
- wiki / documentation

0 comments on commit 54c8c3a

Please sign in to comment.