Skip to content

Commit

Permalink
Merge pull request #3246 from rparree/parameter-required-field
Browse files Browse the repository at this point in the history
fixed parameter object in OpenAPI is not required
  • Loading branch information
adamw authored Oct 16, 2023
2 parents b25ae16 + 623d0fb commit 0f86d74
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object OpenapiModels {
case class OpenapiParameter(
name: String,
in: String,
required: Boolean,
required: Option[Boolean],
description: Option[String],
schema: OpenapiSchemaType
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class EndpointGeneratorSpec extends CompileCheckTestBase {
Seq(
OpenapiPathMethod(
methodType = "get",
parameters = Seq(Resolved(OpenapiParameter("asd-id", "path", true, None, OpenapiSchemaString(false)))),
parameters = Seq(Resolved(OpenapiParameter("asd-id", "path", Some(true), None, OpenapiSchemaString(false)))),
responses = Seq(
OpenapiResponse(
"200",
Expand Down Expand Up @@ -136,7 +136,7 @@ class EndpointGeneratorSpec extends CompileCheckTestBase {
Seq(
OpenapiPathMethod(
methodType = "get",
parameters = Seq(Resolved(OpenapiParameter("id", "path", true, None, OpenapiSchemaString(true)))),
parameters = Seq(Resolved(OpenapiParameter("id", "path", Some(true), None, OpenapiSchemaString(true)))),
responses = Seq(
OpenapiResponse("202", "Processing", Seq(OpenapiResponseContent("text/plain", OpenapiSchemaString(false)))),
OpenapiResponse("404", "couldn't find thing", Seq(OpenapiResponseContent("text/plain", OpenapiSchemaString(false))))
Expand All @@ -152,7 +152,7 @@ class EndpointGeneratorSpec extends CompileCheckTestBase {
Seq(
OpenapiPathMethod(
methodType = "get",
parameters = Seq(Resolved(OpenapiParameter("id", "path", true, None, OpenapiSchemaString(true)))),
parameters = Seq(Resolved(OpenapiParameter("id", "path", Some(true), None, OpenapiSchemaString(true)))),
responses = Seq(
OpenapiResponse("204", "No body", Nil),
OpenapiResponse("403", "Not authorised", Nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ object TestHelpers {
| parameters:
| - name: genre
| in: path
| required: true
| schema:
| type: string
| - $ref: '#/components/parameters/year'
Expand Down Expand Up @@ -157,10 +156,12 @@ object TestHelpers {
OpenapiPathMethod(
methodType = "get",
parameters = Seq(
Resolved(OpenapiParameter("genre", "path", true, None, OpenapiSchemaString(false))),
Resolved(OpenapiParameter("genre", "path", Some(true), None, OpenapiSchemaString(false))),
Ref[OpenapiParameter]("#/components/parameters/offset"),
Resolved(OpenapiParameter("limit", "query", true, Some("Maximum number of books to retrieve"), OpenapiSchemaInt(false))),
Resolved(OpenapiParameter("X-Auth-Token", "header", true, None, OpenapiSchemaString(false)))
Resolved(
OpenapiParameter("limit", "query", Some(true), Some("Maximum number of books to retrieve"), OpenapiSchemaInt(false))
),
Resolved(OpenapiParameter("X-Auth-Token", "header", Some(true), None, OpenapiSchemaString(false)))
),
responses = Seq(
OpenapiResponse(
Expand All @@ -178,9 +179,11 @@ object TestHelpers {
OpenapiPathMethod(
methodType = "post",
parameters = Seq(
Resolved(OpenapiParameter("year", "path", true, None, OpenapiSchemaInt(false))),
Resolved(OpenapiParameter("limit", "query", true, Some("Maximum number of books to retrieve"), OpenapiSchemaInt(false))),
Resolved(OpenapiParameter("X-Auth-Token", "header", true, None, OpenapiSchemaString(false)))
Resolved(OpenapiParameter("year", "path", Some(true), None, OpenapiSchemaInt(false))),
Resolved(
OpenapiParameter("limit", "query", Some(true), Some("Maximum number of books to retrieve"), OpenapiSchemaInt(false))
),
Resolved(OpenapiParameter("X-Auth-Token", "header", Some(true), None, OpenapiSchemaString(false)))
),
responses = Seq(
OpenapiResponse(
Expand Down Expand Up @@ -219,7 +222,7 @@ object TestHelpers {
)
),
parameters = Seq(
Resolved(OpenapiParameter("genre", "path", true, None, OpenapiSchemaString(false))),
Resolved(OpenapiParameter("genre", "path", None, None, OpenapiSchemaString(false))),
Ref("#/components/parameters/year")
)
)
Expand All @@ -232,8 +235,8 @@ object TestHelpers {
securitySchemes = Map.empty,
parameters = Map(
"#/components/parameters/offset" ->
OpenapiParameter("offset", "query", true, Some("Offset at which to start fetching books"), OpenapiSchemaInt(false)),
"#/components/parameters/year" -> OpenapiParameter("year", "path", true, None, OpenapiSchemaInt(false))
OpenapiParameter("offset", "query", Some(true), Some("Offset at which to start fetching books"), OpenapiSchemaInt(false)),
"#/components/parameters/year" -> OpenapiParameter("year", "path", Some(true), None, OpenapiSchemaInt(false))
)
)
)
Expand Down Expand Up @@ -315,7 +318,7 @@ object TestHelpers {
OpenapiPathMethod(
methodType = "get",
parameters = Seq(
Resolved(OpenapiParameter("name", "query", true, None, OpenapiSchemaString(false)))
Resolved(OpenapiParameter("name", "query", Some(true), None, OpenapiSchemaString(false)))
),
responses = Seq(
OpenapiResponse(
Expand Down Expand Up @@ -416,7 +419,7 @@ object TestHelpers {
OpenapiPathMethod(
methodType = "get",
Seq(
Resolved(OpenapiParameter("name", "path", true, None, OpenapiSchemaString(false)))
Resolved(OpenapiParameter("name", "path", Some(true), None, OpenapiSchemaString(false)))
),
responses = Seq(
OpenapiResponse(
Expand Down

0 comments on commit 0f86d74

Please sign in to comment.