redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

Allow split command to group by naming convention then write each group to their own file.

Open mdh09 opened this issue 4 months ago • 1 comments

We have naming conventions to our schemas and would like to know if it's possible to group schemas with similar naming conventions together. By naming convention, we have schemas like Architype.Date, Architype.Name, Models.Contracts, Models.Vehicles, Properties.StopDate, Properties.ContractNumber. Properties schemas usually $ref an Architype schema. Model schemas usually $ref multiple Properties schemas.

The split command is great in that there's not a single giant file, but having hundreds of little files makes navigation a nightmare.

Having the ability to group schemas with the same conventions (Architype, Models, Properties, etc) into the same file would lessen the numbers of files created by the split's default functionality. By this I mean, all the Architype schemas go into a single Architype.json file; all the Properties schemas would go into a single Properties.json file; etc...

As to what that would look like: Option 1. Add a new extension x-SchemaGroup. This extension would be added to each of the schemas. An example would be: SchemaGroupExtensionExample The split command would have an option --SplitBySchemaGroup and the process would group by the extension and create 1 file per x-SchemaGroup defined.

Option 2. Lean on the Name of the schemas. For example, only allow a schema name to have 1 or maybe 2 delimiters. This would be the . in the following case. image From there, the process would be similar to option 1 only that instead of grouping by the extension, the grouping be by the first word before the delimiter.

There could be more options, but these 2 were the most transparent options in my head.

Thank you in advance!

mdh09 avatar Apr 04 '24 18:04 mdh09