forked from zio/zio-http
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gen] dictionaries with referenced keys extension (zio#3043)
- Loading branch information
Showing
15 changed files
with
643 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package test.component | ||
|
||
import zio.prelude.Newtype | ||
import zio.schema.Schema | ||
import java.util.UUID | ||
|
||
object OrderId extends Newtype[UUID] { | ||
implicit val schema: Schema[OrderId.Type] = Schema.primitive[UUID].transform(wrap, unwrap) | ||
} |
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,9 @@ | ||
package test.component | ||
|
||
import zio.prelude.Newtype | ||
import zio.schema.Schema | ||
import java.util.UUID | ||
|
||
object UserId extends Newtype[UUID] { | ||
implicit val schema: Schema[UserId.Type] = Schema.primitive[UUID].transform(wrap, unwrap) | ||
} |
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,14 @@ | ||
package test.component | ||
|
||
import zio.schema._ | ||
import java.util.UUID | ||
|
||
case class Order( | ||
id: UUID, | ||
product: String, | ||
@zio.schema.annotation.validate[Int](zio.schema.validation.Validation.greaterThan(0)) quantity: Int, | ||
@zio.schema.annotation.validate[Double](zio.schema.validation.Validation.greaterThan(-1.0)) price: Double, | ||
) | ||
object Order { | ||
implicit val codec: Schema[Order] = DeriveSchema.gen[Order] | ||
} |
13 changes: 13 additions & 0 deletions
13
zio-http-gen/src/test/resources/ComponentOrderWithAliases.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,13 @@ | ||
package test.component | ||
|
||
import zio.schema._ | ||
|
||
case class Order( | ||
id: OrderId.Type, | ||
product: String, | ||
@zio.schema.annotation.validate[Int](zio.schema.validation.Validation.greaterThan(0)) quantity: Int, | ||
@zio.schema.annotation.validate[Double](zio.schema.validation.Validation.greaterThan(-1.0)) price: Double, | ||
) | ||
object Order { | ||
implicit val codec: Schema[Order] = DeriveSchema.gen[Order] | ||
} |
12 changes: 12 additions & 0 deletions
12
zio-http-gen/src/test/resources/ComponentUserOrderHistory.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,12 @@ | ||
package test.component | ||
|
||
import zio.schema._ | ||
import java.util.UUID | ||
|
||
case class UserOrderHistory( | ||
user_id: UUID, | ||
history: Map[UUID, Order], | ||
) | ||
object UserOrderHistory { | ||
implicit val codec: Schema[UserOrderHistory] = DeriveSchema.gen[UserOrderHistory] | ||
} |
11 changes: 11 additions & 0 deletions
11
zio-http-gen/src/test/resources/ComponentUserOrderHistoryWithAliases.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,11 @@ | ||
package test.component | ||
|
||
import zio.schema._ | ||
|
||
case class UserOrderHistory( | ||
user_id: UserId.Type, | ||
history: Map[OrderId.Type, Order], | ||
) | ||
object UserOrderHistory { | ||
implicit val codec: Schema[UserOrderHistory] = DeriveSchema.gen[UserOrderHistory] | ||
} |
67 changes: 67 additions & 0 deletions
67
zio-http-gen/src/test/resources/inline_schema_constrained_inlined_keys_map.yaml
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,67 @@ | ||
info: | ||
title: Shop Service | ||
version: 0.0.1 | ||
servers: | ||
- url: http://127.0.0.1:5000/ | ||
tags: | ||
- name: Order_API | ||
paths: | ||
/api/v1/shop/history/{id}: | ||
get: | ||
operationId: get_user_history | ||
parameters: | ||
- in: path | ||
name: id | ||
schema: | ||
type: string | ||
format: uuid | ||
required: true | ||
tags: | ||
- Order_API | ||
description: Get user order history by user id | ||
responses: | ||
"200": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/UserOrderHistory' | ||
description: OK | ||
openapi: 3.0.3 | ||
components: | ||
schemas: | ||
UserOrderHistory: | ||
type: object | ||
required: | ||
- user_id | ||
- history | ||
properties: | ||
user_id: | ||
type: string | ||
format: uuid | ||
history: | ||
type: object | ||
additionalProperties: | ||
$ref: '#/components/schemas/Order' | ||
x-string-key-schema: | ||
type: string | ||
format: uuid | ||
Order: | ||
type: object | ||
required: | ||
- id | ||
- product | ||
- quantity | ||
- price | ||
properties: | ||
id: | ||
type: string | ||
format: uuid | ||
product: | ||
type: string | ||
quantity: | ||
type: integer | ||
format: int32 | ||
minimum: 1 | ||
price: | ||
type: number | ||
minimum: 0 |
69 changes: 69 additions & 0 deletions
69
zio-http-gen/src/test/resources/inline_schema_constrained_keys_map.yaml
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,69 @@ | ||
info: | ||
title: Shop Service | ||
version: 0.0.1 | ||
servers: | ||
- url: http://127.0.0.1:5000/ | ||
tags: | ||
- name: Order_API | ||
paths: | ||
/api/v1/shop/history/{id}: | ||
get: | ||
operationId: get_user_history | ||
parameters: | ||
- in: path | ||
name: id | ||
schema: | ||
$ref: '#/components/schemas/UserId' | ||
required: true | ||
tags: | ||
- Order_API | ||
description: Get user order history by user id | ||
responses: | ||
"200": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/UserOrderHistory' | ||
description: OK | ||
openapi: 3.0.3 | ||
components: | ||
schemas: | ||
UserOrderHistory: | ||
type: object | ||
required: | ||
- user_id | ||
- history | ||
properties: | ||
user_id: | ||
$ref: '#/components/schemas/UserId' | ||
history: | ||
type: object | ||
additionalProperties: | ||
$ref: '#/components/schemas/Order' | ||
x-string-key-schema: | ||
$ref: '#/components/schemas/OrderId' | ||
Order: | ||
type: object | ||
required: | ||
- id | ||
- product | ||
- quantity | ||
- price | ||
properties: | ||
id: | ||
$ref: '#/components/schemas/OrderId' | ||
product: | ||
type: string | ||
quantity: | ||
type: integer | ||
format: int32 | ||
minimum: 1 | ||
price: | ||
type: number | ||
minimum: 0 | ||
OrderId: | ||
type: string | ||
format: uuid | ||
UserId: | ||
type: string | ||
format: uuid |
69 changes: 69 additions & 0 deletions
69
zio-http-gen/src/test/resources/inline_schema_constrained_keys_map_wrong_type.yaml
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,69 @@ | ||
info: | ||
title: Shop Service | ||
version: 0.0.1 | ||
servers: | ||
- url: http://127.0.0.1:5000/ | ||
tags: | ||
- name: Order_API | ||
paths: | ||
/api/v1/shop/history/{id}: | ||
get: | ||
operationId: get_user_history | ||
parameters: | ||
- in: path | ||
name: id | ||
schema: | ||
$ref: '#/components/schemas/UserId' | ||
required: true | ||
tags: | ||
- Order_API | ||
description: Get user order history by user id | ||
responses: | ||
"200": | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/UserOrderHistory' | ||
description: OK | ||
openapi: 3.0.3 | ||
components: | ||
schemas: | ||
UserOrderHistory: | ||
type: object | ||
required: | ||
- user_id | ||
- history | ||
properties: | ||
user_id: | ||
$ref: '#/components/schemas/UserId' | ||
history: | ||
type: object | ||
additionalProperties: | ||
$ref: '#/components/schemas/Order' | ||
x-string-key-schema: | ||
$ref: '#/components/schemas/OrderId' | ||
Order: | ||
type: object | ||
required: | ||
- id | ||
- product | ||
- quantity | ||
- price | ||
properties: | ||
id: | ||
$ref: '#/components/schemas/OrderId' | ||
product: | ||
type: string | ||
quantity: | ||
type: integer | ||
format: int32 | ||
minimum: 1 | ||
price: | ||
type: number | ||
minimum: 0 | ||
OrderId: | ||
type: integer | ||
format: int32 | ||
UserId: | ||
type: string | ||
format: uuid |
Oops, something went wrong.