-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- named types with provider now work - use AssetOrArchive in TypeMapper - fix union fallback type regression - eliminate redundant unions, e.g. String | String - fix missing key when package mapping present
- Loading branch information
1 parent
c24de3b
commit a4fc5f5
Showing
9 changed files
with
211 additions
and
114 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package besom.codegen.metaschema | ||
|
||
import besom.codegen.Utils.TypeReferenceOps | ||
import besom.codegen.{Config, DownloadingSchemaProvider, Logger, PackageMetadata, TypeMapper, UpickleApi} | ||
|
||
//noinspection ScalaFileName,TypeAnnotation | ||
class PulumiPackageTest extends munit.FunSuite { | ||
implicit val logger: Logger = new Logger | ||
private val defaultTestSchemaName = "test-as-scala-type" | ||
|
||
test("TypeReference with nested union and named types") { | ||
val json = | ||
"""|{ | ||
| "type": "string", | ||
| "oneOf": [ | ||
| { | ||
| "type": "string" | ||
| }, | ||
| { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string", | ||
| "$ref": "#/types/aws:s3%2FroutingRules:RoutingRule" | ||
| } | ||
| } | ||
| ] | ||
|} | ||
|""".stripMargin | ||
|
||
val propertyDefinition = UpickleApi.read[PropertyDefinition](json) | ||
|
||
val schemaProvider = new DownloadingSchemaProvider(schemaCacheDirPath = Config.DefaultSchemasDir) | ||
val (_, packageInfo) = schemaProvider.packageInfo( | ||
PulumiPackage(defaultTestSchemaName), | ||
PackageMetadata(defaultTestSchemaName, "0.0.0") | ||
) | ||
implicit val tm: TypeMapper = new TypeMapper(packageInfo, schemaProvider) | ||
val typeReferenceScala = propertyDefinition.typeReference.asScalaType() | ||
assertEquals(typeReferenceScala.toString(), "String | scala.collection.immutable.List[String]") | ||
} | ||
} |
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
Oops, something went wrong.