j-d-carmichael / boats

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

Ignore file name in definitions when the folder and the filename matches #8

Closed jonmanga closed 4 years ago

jonmanga commented 4 years ago

Given a definition like /star-wars/StarWars.yml to output in generated definitions will only be StarWars instead of StarWarsStarWars

j-d-carmichael commented 4 years ago

Not totally opposed to merging this in, but what is the use case? I mean, when would this happen?

p-mcgowan commented 4 years ago

does this only trim them when filename and dirname match?

for example, if we have /star-wars/starWars.yml but also /star-wars/get.yml, will 1 be starWars and the other get?

This may be something that should be configurable as opposed to one or the other - for example

  {{ autoDefinitionIndexer({ dropBaseName: true }) }}
jonmanga commented 4 years ago

@p-mcgowan it's only for Models/Definitions. The trim will on act on the first instance. Instead of StartWarsStarWars you'll get StartWars in the second case you'll get StarWarsGet.

I didn't think anyone would want duplicate names in their models that's why I made it mandatory. However, we agreed with @johndcarmichael to make it configurable as you suggested above.

p-mcgowan commented 4 years ago

ah cool - yeah that makes sense

jonmanga commented 4 years ago

Update to use:

{{ autoDefinitionIndexer({ dropBaseName: true }) }}
j-d-carmichael commented 4 years ago

@jonmanga looks good except to make this easier for 3rd parties to understand and as this is not typescript could you add a jsdoc to the nunjucksHelpers/autoComponentIndexer.js then we can roll it out.

Remove is either a string or an object, but this is not clear unless you chase the code through.

The docs of your new feature needs a few words too on the branch gh-pages: https://github.com/johndcarmichael/boats/blob/gh-pages/README.md#auto-index-files