hashicorp / terraform-plugin-codegen-openapi

OpenAPI to Terraform Provider Code Generation Specification
Mozilla Public License 2.0
49 stars 9 forks source link

Enable Configuration to Consolidate Path Parameters with Existing Schema #33

Closed bflad closed 1 year ago

bflad commented 1 year ago

In an OpenAPI specification, a path parameter may have a slightly differing name than the associated object property. For example, in the pet store:

    "paths": {
        "/pet/{petId}": {
            "get": {
                "tags": [
                    "pet"
                ],
                "summary": "Find pet by ID",
                "description": "Returns a single pet",
                "operationId": "getPetById",
                "parameters": [
                    {
                        "name": "petId",
                        "in": "path",
                        "description": "ID of pet to return",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int64"
                        }
                    }
                ],
...
    "components": {
        "schemas": {
            "Pet": {
                "properties": {
                    "id": {
                        "type": "integer",
                        "format": "int64",
                        "example": 10
                    },

This currently causes the specification output:

    "resources": [
        {
            "name": "pet",
            "schema": {
                "attributes": [
                    {
                        "name": "id",
                        "int64": {
                            "computed_optional_required": "computed_optional",
                            "description": ""
                        }
                    },
                    {
                        "name": "petId",
                        "int64": {
                            "computed_optional_required": "computed_optional",
                            "description": "ID of pet to return"
                        }
                    }

Ideally, there would be some method to configure the converter to consolidate this to a single attribute with name id. The specification may need its own way to annotate the difference between API handling of petId versus id to support fully generating a data source or resource.

github-actions[bot] commented 3 months ago

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.