diff --git a/TopModel.Core/schema.tmdgen.config.json b/TopModel.Core/schema.tmdgen.config.json index f3728032..938889d2 100644 --- a/TopModel.Core/schema.tmdgen.config.json +++ b/TopModel.Core/schema.tmdgen.config.json @@ -247,6 +247,10 @@ "preservePropertyCasing": { "type": "boolean", "description": "Garde les noms des propriétés générées tels quels pour la génération via `modgen`, au lieu de les convertir dans le format du langage cible. Par défaut : `true`." + }, + "classPrefix": { + "type": "string", + "description": "Préfixe à ajouter à toutes les classes générées pour cette source." } } } diff --git a/TopModel.ModelGenerator/OpenApi/OpenApiTmdGenerator.cs b/TopModel.ModelGenerator/OpenApi/OpenApiTmdGenerator.cs index ec478d3a..9d41c0df 100644 --- a/TopModel.ModelGenerator/OpenApi/OpenApiTmdGenerator.cs +++ b/TopModel.ModelGenerator/OpenApi/OpenApiTmdGenerator.cs @@ -80,7 +80,7 @@ protected override async IAsyncEnumerable GenerateCore() var className = schema.Value.Type == "array" ? schema.Key.Unplurialize() : schema.Key; - fw.WriteLine($" name: {className}"); + fw.WriteLine($" name: {_config.ClassPrefix}{className}"); if (_config.PreservePropertyCasing) { @@ -110,7 +110,7 @@ protected override async IAsyncEnumerable GenerateCore() else { fw.WriteLine(" - alias:"); - fw.WriteLine($@" class: {schema.Key.ToPascalCase()}{property.Key.ToPascalCase()}"); + fw.WriteLine($@" class: {_config.ClassPrefix}{schema.Key.ToPascalCase()}{property.Key.ToPascalCase()}"); fw.WriteLine($" name: {property.Key.ToPascalCase()}"); } @@ -124,7 +124,7 @@ protected override async IAsyncEnumerable GenerateCore() { fw.WriteLine("---"); fw.WriteLine("class:"); - fw.WriteLine($" name: {schema.Key.ToPascalCase()}{property.Key.ToPascalCase()}"); + fw.WriteLine($" name: {_config.ClassPrefix}{schema.Key.ToPascalCase()}{property.Key.ToPascalCase()}"); if (_config.PreservePropertyCasing) { @@ -414,7 +414,7 @@ private void WriteProperty(OpenApiConfig config, FileWriter sw, KeyValuePair