-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #3246 - swapped validation annotations minLength and maxLength …
…in code generated from OpenAPI
- Loading branch information
1 parent
1f8ef1f
commit 3728252
Showing
5 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
zio-http-gen/src/test/resources/EndpointWithRequestResponseBodyInlineMinMaxLength.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,33 @@ | ||
package test.api.v1 | ||
|
||
import test.component._ | ||
import zio.schema._ | ||
|
||
object Entries { | ||
import zio.http._ | ||
import zio.http.endpoint._ | ||
import zio.http.codec._ | ||
val post = Endpoint(Method.POST / "api" / "v1" / "entries") | ||
.in[POST.RequestBody] | ||
.out[POST.ResponseBody](status = Status.Ok) | ||
|
||
object POST { | ||
import zio.schema.annotation.validate | ||
import zio.schema.validation.Validation | ||
|
||
case class RequestBody( | ||
id: Int, | ||
@validate[String](Validation.maxLength(255) && Validation.minLength(1)) name: String, | ||
) | ||
object RequestBody { | ||
implicit val codec: Schema[RequestBody] = DeriveSchema.gen[RequestBody] | ||
} | ||
case class ResponseBody( | ||
id: Int, | ||
@validate[String](Validation.maxLength(255) && Validation.minLength(1)) name: String, | ||
) | ||
object ResponseBody { | ||
implicit val codec: Schema[ResponseBody] = DeriveSchema.gen[ResponseBody] | ||
} | ||
} | ||
} |
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
82 changes: 82 additions & 0 deletions
82
zio-http-gen/src/test/resources/inline_schema_minmaxlength.json
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,82 @@ | ||
{ | ||
"openapi" : "3.1.0", | ||
"info" : { | ||
"title" : "", | ||
"version" : "" | ||
}, | ||
"paths" : { | ||
"/api/v1/entries" : { | ||
"post" : { | ||
"requestBody" : | ||
{ | ||
"content" : { | ||
"application/json" : { | ||
"schema" : | ||
{ | ||
"type" : | ||
"object", | ||
"properties" : { | ||
"id" : { | ||
"type" : | ||
"integer", | ||
"format" : "int32" | ||
}, | ||
"name" : { | ||
"type" : | ||
"string", | ||
"minLength" : 1, | ||
"maxLength" : 255 | ||
} | ||
}, | ||
"additionalProperties" : | ||
true, | ||
"required" : [ | ||
"id", | ||
"name" | ||
] | ||
} | ||
|
||
} | ||
}, | ||
"required" : true | ||
}, | ||
"responses" : { | ||
"200" : | ||
{ | ||
"description" : "", | ||
"content" : { | ||
"application/json" : { | ||
"schema" : | ||
{ | ||
"type" : | ||
"object", | ||
"properties" : { | ||
"id" : { | ||
"type" : | ||
"integer", | ||
"format" : "int32" | ||
}, | ||
"name" : { | ||
"type" : | ||
"string", | ||
"minLength" : 1, | ||
"maxLength" : 255 | ||
} | ||
}, | ||
"additionalProperties" : | ||
true, | ||
"required" : [ | ||
"id", | ||
"name" | ||
] | ||
} | ||
|
||
} | ||
} | ||
} | ||
}, | ||
"deprecated" : false | ||
} | ||
} | ||
} | ||
} |
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