-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:TinkoffCreditSystems/typed-schema
- Loading branch information
Showing
9 changed files
with
107 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,5 @@ object Version { | |
|
||
val typedSchema = "0.12.6" | ||
|
||
val swaggerUI = "3.35.1" | ||
val swaggerUI = "3.35.2" | ||
} |
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
58 changes: 58 additions & 0 deletions
58
modules/swagger/src/main/scala/ru/tinkoff/tschema/swagger/SwaggerFunctions.scala
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,58 @@ | ||
package ru.tinkoff.tschema.swagger | ||
|
||
import cats.Eval | ||
|
||
trait SwaggerFunctions { | ||
import SwaggerTypeable.make | ||
|
||
def typeOf[A](implicit swagger: Swagger[A]): SwaggerType = swagger.typ | ||
|
||
def obj[A](props: (String, SwaggerType)*): Swagger[A] = make( | ||
SwaggerObject( | ||
props.map { case (name, typ) => SwaggerProperty(name, None, typ = Eval.now(typ)) }.toVector | ||
) | ||
) | ||
|
||
def objLazy[A](props: (String, () => SwaggerType)*): Swagger[A] = make( | ||
SwaggerObject( | ||
props.map { case (name, typ) => SwaggerProperty(name, None, typ = Eval.later(typ())) }.toVector | ||
) | ||
) | ||
|
||
def arr[A](t: => SwaggerType): Swagger[A] = | ||
SwaggerTypeable.make(SwaggerArray(Eval.later(t))) | ||
|
||
def oneOf[A](ts: SwaggerType*): Swagger[A] = make( | ||
SwaggerOneOf(ts.map(t => None -> Eval.now(t)).toVector) | ||
) | ||
|
||
def oneOfLazy[A](ts: () => SwaggerType*): Swagger[A] = make( | ||
SwaggerOneOf(ts.map(t => None -> Eval.later(t())).toVector) | ||
) | ||
|
||
def discriminated[A](discriminator: String)(ts: (String, SwaggerType)*): Swagger[A] = make( | ||
SwaggerOneOf(ts.map { case (name, t) => Some(name) -> Eval.now(t) }.toVector) | ||
) | ||
|
||
def discriminatedLazy[A](discriminator: String)(ts: (String, () => SwaggerType)*): Swagger[A] = | ||
SwaggerTypeable.make( | ||
SwaggerOneOf(ts.map { case (name, t) => Some(name) -> Eval.later(t()) }.toVector) | ||
) | ||
|
||
//usage : Swagger.string(_(format = OpenApiFormat.password, maxLength = 30)) | ||
def string[A](create: SwaggerStringValue.type => SwaggerStringValue): Swagger[A] = | ||
SwaggerTypeable.make( | ||
new SwaggerPrimitive(create(SwaggerStringValue)) | ||
) | ||
|
||
//usage : Swagger.int(_(format = OpenApiFormat.int64, minimum = 1)) | ||
def int[A](create: SwaggerIntValue.type => SwaggerIntValue): Swagger[A] = | ||
SwaggerTypeable.make( | ||
new SwaggerPrimitive(create(SwaggerIntValue)) | ||
) | ||
|
||
def number[A](create: SwaggerNumberValue.type => SwaggerNumberValue): Swagger[A] = | ||
SwaggerTypeable.make( | ||
new SwaggerPrimitive(create(SwaggerNumberValue)) | ||
) | ||
} |
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
Oops, something went wrong.