Skip to content

0.22.2 break code generated by swagger #160

@cedric-appdirect

Description

@cedric-appdirect

When using swagger with JSON object that have a minimum value of 0, you end up with a structure that contain a pointer to your value (which can be zero and valid). When using 0.22.2, this result in an error as the test case below will reproduce.

func TestValues_RequiredValidZero(t *testing.T) {
	var err error

	m := struct {
		Percent *int64
	}{
		Percent: new(int64),
	}

	err = Required("percent", "body", m.Percent)
	assert.NoError(t, err)
}

I am suspecting line 170 in value.go introduced by this recent commit 348543c#diff-a9025362efd5a648c10a6bf6ad93e8a7f729eb991a8fb0dd589928d0018921a2R170 from @jiuker . I don't have enough context to propose a correction, but let me know how I can help.

I would think this is a rather important problem to fix as any swagger generated code that pick this new version will get broken.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions