j-d-carmichael / boats

Beautiful Open Api Template System
MIT License
57 stars 8 forks source link

Auto summary helper #67

Closed j-d-carmichael closed 2 years ago

j-d-carmichael commented 2 years ago
summary: get the list you can add to
description: |
  get the list of lists
responses:
  200:
    description: An array of prospects
    schema:
      $ref: ../../../../definitions/list/models.yml

nice.. the tag is a helper and added to the inject helper.. as is the opid etc etc.

But summary is not and it is a pain to manually write this out when the rolder structure should basically be doing this for us.

eg

src/paths/user/{email}/lists/get.yml

Could equate to

Get lists for {email} for users

j-d-carmichael commented 2 years ago

src/paths/user/{email}/lists/get.yml

GET We know the http verb is a kind of action, get, create, update and "update a little bit of" LISTS is the thing we get {email} When {} we know we have a variable, so in English "for $var" usually will make sense user is the harder bit.. specially if there are more

For example this is a harder one

src/paths/user/{email}/action/lists/get.yml

or

src/paths/item/{id}/comment/{id}/like/post.yml

Will be interesting to build a series of potentials on here and see :)

j-d-carmichael commented 2 years ago

Simplified with idea from @p-mcgowan just grab the last url segment and expose to the tpl engine

{{ segments.first }}
{{ segments.secondLast }}
{{ segments.last }}
{{ segments[n] }}
{{ verb }}

then you could just stick that in the injector or wherever else

j-d-carmichael commented 2 years ago

https://github.com/j-d-carmichael/boats/blob/main/src/nunjucksHelpers/autoSummary.ts

Human sentence version released