Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
SMILEY4 committed May 30, 2024
2 parents d0ecec7 + c8994b9 commit 004a50f
Show file tree
Hide file tree
Showing 54 changed files with 1,041 additions and 405 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Schema-Kenerator

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.smiley4/schema-kenerator-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.smiley4/schema-kenerator-core)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.smiley4/schema-kenerator-core/badge.svg)](https://search.maven.org/search?q=g:io.github.smiley4%20a:schema-kenerator-*)
[![Checks Passing](https://github.com/SMILEY4/schema-kenerator/actions/workflows/checks.yml/badge.svg?branch=develop)](https://github.com/SMILEY4/schema-kenerator/actions/workflows/checks.yml)


Expand Down
2 changes: 1 addition & 1 deletion 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=schema-kenerator
projectVersion=0.3.0
projectVersion=0.4.0

# publishing information
projectNameBase=Schema-Kenerator
Expand Down
26 changes: 13 additions & 13 deletions schema-kenerator-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ dependencies {

## Annotations

| Annotation | Description | Relevant Steps |
|----------------------|--------------------------------------------------------------------------------|-----------------------------------------------------|
| `@SchemaName` | Specify a new name for the type. | `renameTypes` (core) |
| `@SchemaTitle` | Provide an additional title for the resulting schema. | `handleTitleAnnotation` (jsonschema, swagger) |
| `@SchemaDescription` | Provide a description for the annotated type or property. | `handleDescriptionAnnotation` (jsonschema, swagger) |
| `@SchemaDeprecated` | Specify whether the annotated type or property should be marked as deprecated. | `handleDeprecatedAnnotation` (jsonschema, swagger) |
| `@SchemaExample` | Provide example values for the annotated type or property | `handleExampleAnnotation` (jsonschema, swagger) |
| `@SchemaDefault` | Specify a default value for the annotated type or property | `handleDefaultAnnotation` (jsonschema, swagger) |
| Annotation | Description | Relevant Steps |
|----------------|--------------------------------------------------------------------------------|-----------------------------------------------|
| `@Name` | Specify a new name for the type. | `handleNameAnnotation` (core) |
| `@Title` | Provide an additional title for the resulting schema. | `handleCoreAnnotations` (jsonschema, swagger) |
| `@Description` | Provide a description for the annotated type or property. | `handleCoreAnnotations` (jsonschema, swagger) |
| `@Deprecated` | Specify whether the annotated type or property should be marked as deprecated. | `handleCoreAnnotations` (jsonschema, swagger) |
| `@Example` | Provide example values for the annotated type or property | `handleCoreAnnotations` (jsonschema, swagger) |
| `@Default` | Specify a default value for the annotated type or property | `handleCoreAnnotations` (jsonschema, swagger) |

## Steps

| Step | Description |
|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `connectSubTypes()` | Adds missing subtype-supertype-relations between processed types. Types not already present in the input are not included. This step is mainly used to find and fix missing connections between types added from other steps. |
| `renameTypes()` | Renames types according to provided `@SchemaName`-annotations. |
| `mergeGetters()` | Removes getter-functions and merges them with their matching properties or creates new properties when no matching one could be found. |
| Step | Description |
|--------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `connectSubTypes()` | Adds missing subtype-supertype-relations between processed types. Types not already present in the input are not included. This step is mainly used to find and fix missing connections between types added from other steps. |
| `mergeGetters()` | Removes getter-functions and merges them with their matching properties or creates new properties when no matching one could be found. |
| `handleNameAnnotation()` | Renames types according to provided `@Name`-annotations. |
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ package io.github.smiley4.schemakenerator.core.annotations
AnnotationTarget.FUNCTION
)
@Retention(AnnotationRetention.RUNTIME)
annotation class SchemaDefault(val default: String)
annotation class Default(val default: String)
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ package io.github.smiley4.schemakenerator.core.annotations
AnnotationTarget.FUNCTION
)
@Retention(AnnotationRetention.RUNTIME)
annotation class SchemaDeprecated(val deprecated: Boolean = true)
annotation class Deprecated(val deprecated: Boolean = true)
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ package io.github.smiley4.schemakenerator.core.annotations
AnnotationTarget.FUNCTION
)
@Retention(AnnotationRetention.RUNTIME)
annotation class SchemaDescription(val description: String)
annotation class Description(val description: String)
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ package io.github.smiley4.schemakenerator.core.annotations
)
@Retention(AnnotationRetention.RUNTIME)
@Repeatable
annotation class SchemaExample(val example: String)
annotation class Example(val example: String)
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ package io.github.smiley4.schemakenerator.core.annotations
AnnotationTarget.CLASS,
)
@Retention(AnnotationRetention.RUNTIME)
annotation class SchemaName(val name: String, val qualifiedName: String = "")
annotation class Name(val name: String, val qualifiedName: String = "")
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ package io.github.smiley4.schemakenerator.core.annotations
AnnotationTarget.CLASS,
)
@Retention(AnnotationRetention.RUNTIME)
annotation class SchemaTitle(val title: String)
annotation class Title(val title: String)
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,9 @@ class CollectionTypeData(
* the type of the items
*/
val itemType: PropertyData,
/**
* whether the items in the collection are unique
*/
val unique: Boolean
) : ObjectTypeData(id, simpleName, qualifiedName, typeParameters, annotations, subtypes, supertypes, members)

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fun Bundle<BaseTypeData>.connectSubTypes(): Bundle<BaseTypeData> {
/**
* See [RenameTypesStep]
*/
fun Bundle<BaseTypeData>.renameTypes(): Bundle<BaseTypeData> {
fun Bundle<BaseTypeData>.handleNameAnnotation(): Bundle<BaseTypeData> {
return RenameTypesStep().process(this)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.github.smiley4.schemakenerator.core.steps

import io.github.smiley4.schemakenerator.core.annotations.SchemaName
import io.github.smiley4.schemakenerator.core.annotations.Name
import io.github.smiley4.schemakenerator.core.data.BaseTypeData
import io.github.smiley4.schemakenerator.core.data.Bundle

/**
* Changes the [BaseTypeData.qualifiedName] and [BaseTypeData.simpleName] to the name specified with a [SchemaName]
* Changes the [BaseTypeData.qualifiedName] and [BaseTypeData.simpleName] to the name specified with a [Name]-annotation.
*/
class RenameTypesStep {

Expand All @@ -18,7 +18,7 @@ class RenameTypesStep {

private fun process(data: BaseTypeData) {
data.annotations
.find { it.name == SchemaName::class.qualifiedName }
.find { it.name == Name::class.qualifiedName }
?.let {
val name = it.values["name"] as String
val qualifiedName = it.values["qualifiedName"] as String
Expand Down
12 changes: 6 additions & 6 deletions schema-kenerator-jackson-jsonschema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ dependencies {

## Supported Jackson Annotations

| Step | Description | Relevant Steps |
|----------------------------|------------------------------------------|------------------------------------------------|
| `@JsonPropertyDescription` | Adds description to annotated properties | `handleJacksonPropertyDescriptionAnnotation()` |
| Step | Description | Relevant Steps |
|----------------------------|------------------------------------------|----------------------------------------|
| `@JsonPropertyDescription` | Adds description to annotated properties | `handleJacksonJsonSchemaAnnotations()` |

## Steps

| Step | Description |
|------------------------------------------------|--------------------------------------------------------------------------------------------------|
| `handleJacksonPropertyDescriptionAnnotation()` | Adds a description to properties according to the jackson `@JsonPropertyDescription`-annotation. |
| Step | Description |
|----------------------------------------|--------------------------------------------------------------------------------------------------|
| `handleJacksonJsonSchemaAnnotations()` | Adds a description to properties according to the jackson `@JsonPropertyDescription`-annotation. |
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import io.github.smiley4.schemakenerator.jackson.jsonschema.steps.JacksonJsonSch
import io.github.smiley4.schemakenerator.jsonschema.data.JsonSchema

/**
* Handles the jackson "JsonPropertyDescription"-annotation.
* See [JacksonJsonSchemaPropertyDescriptionStep]
*/
fun Bundle<JsonSchema>.handleJacksonPropertyDescriptionAnnotation(): Bundle<JsonSchema> {
return JacksonJsonSchemaPropertyDescriptionStep().process(this)
fun Bundle<JsonSchema>.handleJacksonJsonSchemaAnnotations(): Bundle<JsonSchema> {
return this
.let { JacksonJsonSchemaPropertyDescriptionStep().process(this) }
}
15 changes: 8 additions & 7 deletions schema-kenerator-jackson-swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.smiley4/schema-kenerator-jackson-swagger/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.smiley4/schema-kenerator-jackson-swagger)

This project provides steps to support [Jackson](https://github.com/FasterXML/jackson-annotations)-annotations specific to [Swagger](https://github.com/swagger-api/swagger-parser)-schema generation.
This project provides steps to support [Jackson](https://github.com/FasterXML/jackson-annotations)-annotations specific
to [Swagger](https://github.com/swagger-api/swagger-parser)-schema generation.

```kotlin
dependencies {
Expand All @@ -12,12 +13,12 @@ dependencies {

## Supported Jackson Annotations

| Step | Description | Relevant Steps |
|----------------------------|------------------------------------------|------------------------------------------------|
| `@JsonPropertyDescription` | Adds description to annotated properties | `handleJacksonPropertyDescriptionAnnotation()` |
| Step | Description | Relevant Steps |
|----------------------------|------------------------------------------|-------------------------------------|
| `@JsonPropertyDescription` | Adds description to annotated properties | `handleJacksonSwaggerAnnotations()` |

## Steps

| Step | Description |
|------------------------------------------------|--------------------------------------------------------------------------------------------------|
| `handleJacksonPropertyDescriptionAnnotation()` | Adds a description to properties according to the jackson `@JsonPropertyDescription`-annotation. |
| Step | Description |
|-------------------------------------|--------------------------------------------------------------------------------------------------|
| `handleJacksonSwaggerAnnotations()` | Adds a description to properties according to the jackson `@JsonPropertyDescription`-annotation. |
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import io.github.smiley4.schemakenerator.jackson.swagger.steps.JacksonSwaggerPro
import io.github.smiley4.schemakenerator.swagger.data.SwaggerSchema

/**
* Handles the jackson "JsonPropertyDescription"-annotation.
* See [JacksonSwaggerPropertyDescriptionStep]
*/
fun Bundle<SwaggerSchema>.handleJacksonPropertyDescriptionAnnotation(): Bundle<SwaggerSchema> {
return JacksonSwaggerPropertyDescriptionStep().process(this)
fun Bundle<SwaggerSchema>.handleJacksonSwaggerAnnotations(): Bundle<SwaggerSchema> {
return this
.let { JacksonSwaggerPropertyDescriptionStep().process(this) }
}
Loading

0 comments on commit 004a50f

Please sign in to comment.