Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed parameter object in OpenAPI is not required #3246

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading