goa icon indicating copy to clipboard operation
goa copied to clipboard

Regression: User-Defined Example for Custom URI Type Is Ignored in v1.20

Open davideme opened this issue 7 months ago • 0 comments

Description

We define a custom type utils.URL, which is a string with FormatURI, as follows:

var URL = dsl.Type("URL", dsl.String, func() {
    dsl.Format(dsl.FormatURI)
})

When using this type for an attribute and specifying an explicit example, the example is ignored in Goa v1.20 and replaced by the default example (https://example.com/foo). This worked as expected in v1.19.


Steps to Reproduce

  1. Define the custom type as above.

  2. Use it for an attribute with an explicit example:

    Attribute("seller_offer_redirect_url", utils.URL, func() {
        Description("URL to redirect to view the offer in the topi tool")
        Example("http://www.seller.topi.eu/offer/739b63c2-9e58-4964-b38d-4ebb424de242%2Fv1")
    })
    
  3. Generate the OpenAPI/Swagger spec.


Expected Behavior

The provided example URL should appear in the generated OpenAPI spec.


Actual Behavior

The example in the spec is always https://example.com/foo, regardless of the explicit example provided in the design.


Regression

  • v1.19: The explicit example was correctly shown in the generated spec.
  • v1.20: The explicit example is ignored and replaced by the default.

Screenshot

Diff Screenshot


Goa Version

  • v1.19 (works)
  • v1.20 (broken)

Sample Code

var URL = dsl.Type("URL", dsl.String, func() {
    dsl.Format(dsl.FormatURI)
})

Attribute("seller_offer_redirect_url", utils.URL, func() {
    Description("URL to redirect to view the offer in the topi tool")
    Example("http://www.seller.topi.eu/offer/739b63c2-9e58-4964-b38d-4ebb424de242%2Fv1")
})

davideme avatar May 27 '25 08:05 davideme