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

Maps that utilize allOf or oneOf result in an empty single nested attribute #100

Closed
1 task done
austinvalle opened this issue Dec 13, 2023 · 1 comment · Fixed by #101
Closed
1 task done

Maps that utilize allOf or oneOf result in an empty single nested attribute #100

austinvalle opened this issue Dec 13, 2023 · 1 comment · Fixed by #101
Assignees
Labels
bug Something isn't working
Milestone

Comments

@austinvalle
Copy link
Member

austinvalle commented Dec 13, 2023

tfplugingen-openapi CLI version

tfplugingen-openapi module: v0.2.0

OpenAPI Spec File

openapi: 3.1.0
info:
  title: EdgeCase API
  version: 1.0.0
paths:
  /map_test:
    get:
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  map_stringified:
                    $ref: "#/components/schemas/map_allof_oneof_stringified"
    post:
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                map_stringified:
                  $ref: "#/components/schemas/map_allof_oneof_stringified"
components:
  schemas:
    map_allof_oneof_stringified:
      description: This is a map with a stringifed value
      type: object
      additionalProperties:
        allOf:
        - $ref: "#/components/schemas/stringable_number"
    stringable_number:
      oneOf:
      - type: string
      - type: number

Generator Config

provider:
  name: edgecase

resources:
  map_test:
    create:
      path: /map_test
      method: POST
    read:
      path: /map_test
      method: GET

Expected Behavior

Maps (using the additionalProperties property) should be able to leverage nullable and stringable types

{
  "provider": {
    "name": "edgecase"
  },
  "resources": [
    {
      "name": "map_test",
      "schema": {
        "attributes": [
          {
            "name": "map_stringified",
            "map": {
              "computed_optional_required": "computed_optional",
              "element_type": {
                "string": {}
              },
              "description": "This is a map with a stringifed value"
            }
          }
        ]
      }
    }
  ],
  "version": "0.1"
}

Actual Behavior

The map is returned in the IR output as a single nested attribute with no attributes

{
  "provider": {
    "name": "edgecase"
  },
  "resources": [
    {
      "name": "map_test",
      "schema": {
        "attributes": [
          {
            "name": "map_stringified",
            "single_nested": {
              "computed_optional_required": "computed_optional",
              "description": "This is a map with a stringifed value"
            }
          }
        ]
      }
    }
  ],
  "version": "0.1"
}

Additional Information

This bug was originally discovered in the Kubernetes code generation effort

Code of Conduct

  • I agree to follow this project's Code of Conduct
@austinvalle austinvalle added the bug Something isn't working label Dec 13, 2023
@austinvalle austinvalle self-assigned this Dec 13, 2023
@austinvalle austinvalle added this to the v0.2.1 milestone Dec 13, 2023
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
1 participant