-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ditch zio-parser and use a complex regex that does the same (more o…
…r less), since previous implementation was slooooooooow. * propagate configuration to use fields normalization * implement & add relevant annotation when field name been normalized * test suite for normalization logic * add test to verify annotations are add correctly
- Loading branch information
Showing
7 changed files
with
250 additions
and
32 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
22 changes: 22 additions & 0 deletions
22
zio-http-gen/src/test/resources/ComponentOrderWithNormalizedFieldNames.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,22 @@ | ||
package test.component | ||
|
||
import zio.schema._ | ||
import zio.schema.annotation.fieldName | ||
import zio.schema.annotation.validate | ||
import zio.schema.validation.Validation | ||
import java.util.UUID | ||
|
||
case class Order( | ||
@fieldName("2nd item") secondItem: Option[String], | ||
@fieldName("3rd item") thirdItem: Option[String], | ||
@fieldName("num-of-items") | ||
@validate[Int](Validation.greaterThan(0)) numOfItems: Int, | ||
@fieldName("1st item") firstItem: String, | ||
@fieldName("price in dollars") | ||
@validate[Double](Validation.greaterThan(-1.0)) priceInDollars: Double, | ||
@fieldName("PRODUCT_NAME") productNAME: String, | ||
id: UUID, | ||
) | ||
object Order { | ||
implicit val codec: Schema[Order] = DeriveSchema.gen[Order] | ||
} |
76 changes: 76 additions & 0 deletions
76
zio-http-gen/src/test/resources/inline_schema_weird_field_names.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,76 @@ | ||
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_NAME | ||
- num-of-items | ||
- price in dollars | ||
- 1st item | ||
properties: | ||
id: | ||
$ref: '#/components/schemas/OrderId' | ||
PRODUCT_NAME: | ||
type: string | ||
num-of-items: | ||
type: integer | ||
format: int32 | ||
minimum: 1 | ||
price in dollars: | ||
type: number | ||
minimum: 0 | ||
1st item: | ||
type: string | ||
2nd item: | ||
type: string | ||
3rd item: | ||
type: string | ||
OrderId: | ||
type: string | ||
format: uuid | ||
UserId: | ||
type: string | ||
format: uuid |
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.