Proposal: __traits(getComment, symbol)

Sebastiaan Koppe mail at skoppe.eu
Wed Aug 28 09:35:54 UTC 2019


On Wednesday, 28 August 2019 at 09:17:02 UTC, FeepingCreature 
wrote:
> On Wednesday, 28 August 2019 at 09:04:06 UTC, Eugene Wissner 
> wrote:
>> Why can't you just use UDAs instead of comments?
>
> Why does D use comments instead of UDAs? Because I *don't* want 
> to change behavior, I want to extract documentation. Comments 
> are for documentation.

Swagger for Java uses annotations to describe the endpoints.

Just create a Swagger struct (plus helper structs) and use like:

```
@Swagger(ApiResponses([
     ApiResponse(code = 200, message = "...", response = Entity),
     ApiResponse(code = 404, message = "listing not found")
   ]),
   Put("/entities/{id}"),
   Consumes([MediaType.APPLICATION_JSON_VALUE]),
   Produces([MediaType.APPLICATION_JSON_VALUE])
)
Entity endpoint(string id) { ... }
```

I think it beats parsing (or writing) comments...


More information about the Digitalmars-d mailing list