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

Refer to other resources by reference instead of ID #144

Closed
pawelprazak opened this issue Sep 21, 2023 · 6 comments · Fixed by #332 or #343
Closed

Refer to other resources by reference instead of ID #144

pawelprazak opened this issue Sep 21, 2023 · 6 comments · Fixed by #332 or #343
Assignees
Labels
area/codegen Schema to code generator impact/usability Something that impacts users' ability to use the product easily and intuitively kind/improvement An improvement with existing workaround
Milestone

Comments

@pawelprazak
Copy link
Collaborator

pawelprazak commented Sep 21, 2023

TypeScript:

export interface MethodSettingsArgs {
...
  /**
     * ID of the REST API
     */
    restApi: pulumi.Input<string | RestApi>;
...
}

(another example)

What we generate currently:

final case class MethodSettingsArgs private(
...
  restApi: Output[String],
...
)

Relevant schema:

          "restApi": {
            "type": "string",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "string",
                "$ref": "#/types/aws:apigateway%2FrestApi:RestApi"
              }
            ],
            "description": "ID of the REST API\n",
            "willReplaceOnChanges": true
          },
@pawelprazak pawelprazak added kind/improvement An improvement with existing workaround area/codegen Schema to code generator impact/usability Something that impacts users' ability to use the product easily and intuitively labels Sep 21, 2023
@pawelprazak
Copy link
Collaborator Author

This might be related: pulumi/pulumi#8412

@lbialy
Copy link
Collaborator

lbialy commented Sep 22, 2023

How does it work? What is the definition of RestAPI resource?

@pawelprazak
Copy link
Collaborator Author

this codegen log looks related:

Warning: Type URI #/types/aws:apigateway%2FrestApi:RestApi has no corresponding type definition - using its underlying type as fallback

@pawelprazak pawelprazak self-assigned this Nov 10, 2023
pawelprazak added a commit that referenced this issue Nov 13, 2023
- allow for a union of ID and Resource in inputs

Fixes #144
@pawelprazak
Copy link
Collaborator Author

pawelprazak commented Nov 13, 2023

I was able to get the correct type resolved in unit tests, from this schema:

{
  "type": "string",
  "oneOf": [
    {
      "type": "string"
    },
    {
      "type": "string",
      "$ref": "#/types/aws:apigateway%2FrestApi:RestApi"
    }
  ],
  "willReplaceOnChanges": true
}

into String | besom.api.aws.apigateway.RestApi

but, there is another issue, the generated code has Args suffix:

[error] ./.out/codegen/aws/6.5.0/src/apigateway/AuthorizerArgs.scala:13:23
[error] Encoder for besom.internal.Output[scala.Predef.String | besom.api.aws.apigateway.RestApiArgs] was not found!
[error] ) derives besom.types.ArgsEncoder

@pawelprazak
Copy link
Collaborator Author

Added to codegen in #332

pawelprazak added a commit that referenced this issue Dec 19, 2023
@pawelprazak
Copy link
Collaborator Author

Almost there:

=> Diff (- obtained, + expected)
-String | besom.api.aws.apigateway.RestApiArgs
+String | besom.api.aws.apigateway.RestApi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen Schema to code generator impact/usability Something that impacts users' ability to use the product easily and intuitively kind/improvement An improvement with existing workaround
Projects
None yet
2 participants