-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DefaultValueHook for setting default operation parameter values (#…
…270)
- Loading branch information
1 parent
ba61720
commit f2f46ef
Showing
9 changed files
with
65 additions
and
12 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
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
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
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
13 changes: 13 additions & 0 deletions
13
openapi-generator/src/main/kotlin/org/jellyfin/openapi/hooks/DefaultValueHook.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,13 @@ | ||
package org.jellyfin.openapi.hooks | ||
|
||
import com.squareup.kotlinpoet.TypeName | ||
import io.swagger.v3.oas.models.parameters.Parameter | ||
import org.jellyfin.openapi.model.CustomDefaultValue | ||
|
||
interface DefaultValueHook { | ||
/** | ||
* Create a [CustomDefaultValue] to use when generating the code for this parameter. | ||
* Return `null` if the hook does not want to modify the default value. | ||
*/ | ||
fun onBuildDefaultValue(path: ApiTypePath, type: TypeName, parameterSpec: Parameter): CustomDefaultValue? | ||
} |
19 changes: 19 additions & 0 deletions
19
openapi-generator/src/main/kotlin/org/jellyfin/openapi/model/CustomDefaultValue.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,19 @@ | ||
package org.jellyfin.openapi.model | ||
|
||
import com.squareup.kotlinpoet.CodeBlock | ||
|
||
/** | ||
* Custom value builder used in hooks. | ||
* The implementation should use a [CodeBlock.Builder] to create a value. | ||
* | ||
* Creating a default value with the integer 1 can be done with: | ||
* | ||
* ```kotlin | ||
* CodeBlock.Builder() | ||
* .add("1") | ||
* .build() | ||
* ``` | ||
*/ | ||
interface CustomDefaultValue { | ||
fun build(): CodeBlock | ||
} |