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

W-13992415: fix oas to oas nullable parameter emission #1893

Merged
merged 3 commits into from
Oct 30, 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 @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package amf.apicontract.internal.transformation.compatibility

import amf.apicontract.internal.transformation.Oas30TransformationPipeline
import amf.apicontract.internal.transformation.compatibility.common.SemanticFlattenFilter
import amf.apicontract.internal.transformation.compatibility.oas.CleanNullSecurity
import amf.apicontract.internal.transformation.compatibility.oas3._
import amf.core.client.common.transform._
import amf.core.client.scala.transform.{TransformationPipeline, TransformationStep}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,11 +22,30 @@ class CompatibilityCycleTest extends AsyncFunSuite with FileAssertionTest {
private val basePath = "amf-cli/shared/src/test/resources/compatibility/"

test("RAML with union of nil + type to OAS 3.0") {
compatibility("raml10/union-nil-plus-element.raml", "oas30/union-nil-plus-element.yaml", Raml10YamlHint, Oas30YamlHint)
compatibility(
"raml10/union-nil-plus-element.raml",
"oas30/union-nil-plus-element.yaml",
Raml10YamlHint,
Oas30YamlHint
)
}

test("RAML with union of nil + multiple types to OAS 3.0") {
compatibility("raml10/union-nil-plus-elements.raml", "oas30/union-nil-plus-elements.yaml", Raml10YamlHint, Oas30YamlHint)
compatibility(
arielmirra marked this conversation as resolved.
Show resolved Hide resolved
"raml10/union-nil-plus-elements.raml",
"oas30/union-nil-plus-elements.yaml",
Raml10YamlHint,
Oas30YamlHint
)
}

test("OAS 3.0 with nullable parameter to JSON") {
arielmirra marked this conversation as resolved.
Show resolved Hide resolved
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. */
Expand Down Expand Up @@ -56,4 +75,4 @@ class CompatibilityCycleTest extends AsyncFunSuite with FileAssertionTest {
resolved <- Future.successful(AMFTransformer.transform(unit.baseUnit, PipelineId.Compatibility, toConfig))
} yield resolved.baseUnit
}
}
}