Open
Description
Config Files
In my OpenAPI Spec, I have the following OpenAPI spec:
openapi: 3.0.1
info:
title: Swagger Petstore
description: ""
version: 1.0.6
servers:
- url: https://petstore.swagger.io/v2
paths:
/pet/{id}:
get:
summary: Find pet by ID
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
"200":
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
$ref: '#/components/schemas/Pet'
post:
summary: Updates a pet in the store with form data
parameters:
- name: id
in: path
description: ID of pet that needs to be updated
required: true
schema:
type: string
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
name:
type: string
description: Updated name of the pet
status:
type: string
description: Updated status of the pet
responses:
"200":
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
$ref: '#/components/schemas/Pet'
components:
schemas:
Pet:
required:
- name
type: object
properties:
id:
type: integer
format: int64
name:
type: string
example: doggie
xml:
name: Pet
Coupled with the generator config:
provider:
name: pet
resources:
pet:
read:
path: /pet/{id}
method: GET
create:
path: /pet/{id}
method: POST
data_sources:
pet:
read:
path: /pet/{id}
method: GET
Result Files
When the code spec is generated (tfplugingen-openapi generate --config ./generator_config.yml --output ./provider_code_spec.json ./swagger.yaml
) we see the attribute id within the datasource defined as a string, but the resource defined as the desired int:
Data Source
{
"name": "id",
"string": {
"computed_optional_required": "required"
}
}
Resource
{
"name": "id",
"int64": {
"computed_optional_required": "computed"
}
},
Expected Outcome
If I change the path in the OpenAPI spec, to /pet/{petId}
the datasource returns the id
as the desired int64 type. The expected outcome is with /pet/{id}
on the data source, the code gen should return an int64
type for data source, as it does in the resource.