diff --git a/_testdata/positive/sample.json b/_testdata/positive/sample.json index 4b387a066..a15f789d6 100644 --- a/_testdata/positive/sample.json +++ b/_testdata/positive/sample.json @@ -798,6 +798,23 @@ } } } + }, + "/testIssue1310": { + "get": { + "operationId": "testIssue1310", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Issue1310" + } + } + } + } + } + } } }, "components": { @@ -1973,6 +1990,27 @@ "type": "string" } } + }, + "Issue1310": { + "description": "An API error", + "type": "object", + "properties": { + "title": { + "description": "A short, human-readable summary of the problem type. This value should not change between occurrences of the error.", + "example": "Bad Request", + "type": "string" + }, + "details": { + "description": "A human-readable explanation specific to this occurrence of the problem.", + "example": "Property foo is required but is missing.", + "type": "string" + }, + "properties": { + "description": "Optional map of properties", + "nullable": true, + "type": "object" + } + } } }, "parameters": { diff --git a/internal/integration/json_test.go b/internal/integration/json_test.go index ed52de314..bcbfd2126 100644 --- a/internal/integration/json_test.go +++ b/internal/integration/json_test.go @@ -184,6 +184,21 @@ func TestJSONGenerics(t *testing.T) { }) } }) + t.Run("Issue1310", func(t *testing.T) { + t.Parallel() + + val := api.Issue1310{ + Title: api.NewOptString("Bad Request"), + Details: api.NewOptString("This is an example error"), + Properties: api.NewOptIssue1310Properties(&api.Issue1310Properties{}), + } + encoded := encodeObject(&val) + + var decoded api.Issue1310 + decodeObject(t, encoded, &decoded) + require.Equal(t, val, decoded) + require.JSONEq(t, string(encoded), string(encodeObject(&decoded))) + }) } func TestJSONArray(t *testing.T) {