Skip to content

Is it ok that email marshaling/unmarshaling regexp does not recognize empty value? #990

@jozseftiborcz

Description

@jozseftiborcz

I was testing api generated by this tool where the schema used the declaration something like this in a response struct:
EmailAddress *openapi_types.Email json:"email_address,omitempty"

However, when the response contains an empty email field , the regex matcher does not fit so unmarshalling stop with panic.

I am not sure if this is the intended behaviour in the above case.
Anyway, the solution would be simply put a length check before regex validation, here:
https://github.com/deepmap/oapi-codegen/blob/master/pkg/types/email.go#L11

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