You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have an optional object that is located under a nested object, omitting the optional object through the terraform code omits the parent object on the request body too.
To Reproduce
With the following swagger YAML -
paths:
/v1/characters:
post:
parameters:
-
name: body
schema:
$ref: '#/definitions/Character'
in: body
required: true
responses:
'200':
description: Character created
schema:
$ref: '#/definitions/Character'
summary: Create character
'/v1/characters/{characterId}':
get:
parameters:
-
name: characterId
in: path
required: true
type: string
responses:
'200':
description: Character fetched.
schema:
$ref: '#/definitions/Character'
summary: Retrieve character
definitions:
Position:
title: Root Type for Position
description: ''
type: object
properties:
x:
type: integer
'y':
type: integer
Character:
title: Root Type for Character
description: ''
required:
- health
type: object
properties:
id:
type: string
readOnly: true
health:
type: integer
position:
$ref: '#/definitions/Position'
pet:
$ref: '#/definitions/Pet'
Pet:
title: Root Type for Pet
description: ''
required:
- health
type: object
properties:
id:
type: string
readOnly: true
health:
type: integer
position:
$ref: '#/definitions/Position'
the following terraform code works fine -
resource "myprovider_characters_v1" "mychar" {
health = 10
position {
x = 1
y = 1
}
pet {
health = 30
position {
x = 2
y = 2
}
}
}
The request body is {"health":10,"pet":{"health":30,"position":{"x":2,"y":2}},"position":{"x":1,"y":1}}
However the following terraform code runs into a problem -
resource "myprovider_characters_v1" "mychar" {
health = 10
position {
x = 1
y = 1
}
pet {
health = 30
}
}
The problematic request body - {"health":10,"position":{"x":1,"y":1}} - skips the pet object because the optional position object is omitted from the terraform code.
Expected behaviour
Omitting optional nested objects continues to include the parent object in the request body.
Additional context
Interestingly, omitting position on the Character level does not cause an issue. This is only a problem for optional objects under nested objects.
Checklist (for admin only)
Don't forget to go through the checklist to make sure the issue is created properly:
I have added a corresponding label (bug) to the issue (right side menu)
I have added this issue to the 'API Terraform Provider' GitHub project (right side menu)
The text was updated successfully, but these errors were encountered:
Describe the bug
If you have an optional object that is located under a nested object, omitting the optional object through the terraform code omits the parent object on the request body too.
To Reproduce
With the following swagger YAML -
the following terraform code works fine -
The request body is
{"health":10,"pet":{"health":30,"position":{"x":2,"y":2}},"position":{"x":1,"y":1}}
However the following terraform code runs into a problem -
The problematic request body -
{"health":10,"position":{"x":1,"y":1}}
- skips thepet
object because the optionalposition
object is omitted from the terraform code.Expected behaviour
Omitting optional nested objects continues to include the parent object in the request body.
Additional context
Interestingly, omitting
position
on theCharacter
level does not cause an issue. This is only a problem for optional objects under nested objects.Checklist (for admin only)
Don't forget to go through the checklist to make sure the issue is created properly:
The text was updated successfully, but these errors were encountered: