goa icon indicating copy to clipboard operation
goa copied to clipboard

meta for externalDocs and deprecated?

Open xlanor opened this issue 7 months ago • 3 comments

I can see the Operations object has these fields, but I've been playing around with the DSL to try and set these fields but have not been able to get it to work.

How does one set them using Meta? Would be nice to have a good example

xlanor avatar Jan 15 '24 14:01 xlanor

Hello, externalDocs is supported via the Docs DSL. There is no support today for deprecated, would be a great contribution though!

raphael avatar Jan 17 '24 04:01 raphael

@raphael - happy to contribute. which DSL would you reccomend I look under to begin working on deprecated?

xlanor avatar Jan 19 '24 06:01 xlanor

Awesome! Probably the most straightforward way of adding Deprecated would be to introduce it as a new DSL function that simply adds a metadata to the method. The OpenAPI code generator would then look at whether this metadata is defined on a method and if so set the Deprecated field on the operation object. This would have to be done in both the v2 and v3 generators.

  • Example that adds a meta entry. In this case the new Deprecated function would get the current scope using eval.Current() and make sure it's a HTTPEndpointExpr, similar to how the route function does it. It would then add the meta entry to the HTTPEndpointExpr object.
  • Here is where we may want to check for the metadata for v3. The check can use the Last method of the MetaExpr type simillar to how mustGenerate works
  • Here is where the Deprecated field would have to be computed/set for v2.
  • The new Deprecated() DSL function that adds the Meta to a method could be added here.

Thank you for taking this on!

raphael avatar Jan 19 '24 06:01 raphael

@raphael - I have a PR ready, just need to run some tests (and write some).

Could you point me at any testing docs for new contribs? I'm getting failed tests even on v3 branch and trying to figure out if I'm missing something other than go test

xlanor avatar Mar 17 '24 17:03 xlanor