diff --git a/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/spec/common/emitter/ParameterEmitters.scala b/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/spec/common/emitter/ParameterEmitters.scala index acbad4813c..24516ebe19 100644 --- a/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/spec/common/emitter/ParameterEmitters.scala +++ b/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/spec/common/emitter/ParameterEmitters.scala @@ -286,12 +286,8 @@ case class OasParametersEmitter( } def emitters(): Seq[EntryEmitter] = { - val results = ListBuffer[EntryEmitter]() - val (oasParameters, ramlParameters) = - parameters.partition(p => - Option(p.schema).isEmpty || p.schema.isInstanceOf[ScalarShape] || p.schema - .isInstanceOf[ArrayShape] || p.schema.isInstanceOf[FileShape] - ) + val results = ListBuffer[EntryEmitter]() + val (oasParameters, ramlParameters) = parameters.partition(isValidOasParam) if (oasParameters.nonEmpty || payloads.nonEmpty) results += OasParameterEmitter(oasParameters, references) diff --git a/amf-cli/shared/src/test/resources/compatibility/oas30/nullable-query-param.json b/amf-cli/shared/src/test/resources/compatibility/oas30/nullable-query-param.json new file mode 100644 index 0000000000..8dc6fa14ac --- /dev/null +++ b/amf-cli/shared/src/test/resources/compatibility/oas30/nullable-query-param.json @@ -0,0 +1,28 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "API", + "version": "1.0.0" + }, + "paths": { + "/customers": { + "get": { + "parameters": [ + { + "in": "query", + "name": "enterpriseCustomerNumber", + "schema": { + "nullable": true, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + } +} diff --git a/amf-cli/shared/src/test/resources/compatibility/oas30/nullable-query-param.yaml b/amf-cli/shared/src/test/resources/compatibility/oas30/nullable-query-param.yaml new file mode 100644 index 0000000000..8c9b7bafa9 --- /dev/null +++ b/amf-cli/shared/src/test/resources/compatibility/oas30/nullable-query-param.yaml @@ -0,0 +1,17 @@ +openapi: 3.0.3 +info: + title: API + version: 1.0.0 + +paths: + /customers: + get: + parameters: + - in: query + name: enterpriseCustomerNumber + schema: + nullable: true + type: string + responses: + '200': + description: OK \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/validations/oas3/nullable-query-param.yaml b/amf-cli/shared/src/test/resources/validations/oas3/nullable-query-param.yaml new file mode 100644 index 0000000000..8c9b7bafa9 --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/oas3/nullable-query-param.yaml @@ -0,0 +1,17 @@ +openapi: 3.0.3 +info: + title: API + version: 1.0.0 + +paths: + /customers: + get: + parameters: + - in: query + name: enterpriseCustomerNumber + schema: + nullable: true + type: string + responses: + '200': + description: OK \ No newline at end of file diff --git a/amf-cli/shared/src/test/scala/amf/emit/CompatibilityCycleTest.scala b/amf-cli/shared/src/test/scala/amf/emit/CompatibilityCycleTest.scala index eb802afbb0..395f249e63 100644 --- a/amf-cli/shared/src/test/scala/amf/emit/CompatibilityCycleTest.scala +++ b/amf-cli/shared/src/test/scala/amf/emit/CompatibilityCycleTest.scala @@ -7,7 +7,7 @@ import amf.core.client.scala.errorhandling.UnhandledErrorHandler import amf.core.client.scala.model.document.BaseUnit import amf.core.client.scala.parse.AMFParser import amf.core.client.scala.transform.AMFTransformer -import amf.core.internal.remote.{Hint, Oas30YamlHint, Raml10YamlHint} +import amf.core.internal.remote.{Hint, Oas30JsonHint, Oas30YamlHint, Raml10YamlHint} import amf.core.internal.resource.StringResourceLoader import amf.io.FileAssertionTest import org.scalatest.Assertion @@ -39,6 +39,15 @@ class CompatibilityCycleTest extends AsyncFunSuite with FileAssertionTest { ) } + test("OAS 3.0 with nullable parameter to JSON") { + compatibility( + "oas30/nullable-query-param.yaml", + "oas30/nullable-query-param.json", + Oas30YamlHint, + Oas30JsonHint + ) + } + /** Compile source with specified hint. Render to temporary file and assert against golden. */ private def compatibility(source: String, golden: String, from: Hint, to: Hint): Future[Assertion] = { for {