Codit / practical-api-guidelines

Practical guidelines for building & designing APIs with .NET.
MIT License
16 stars 5 forks source link

Route names as constants? #91

Closed MassimoC closed 5 years ago

MassimoC commented 5 years ago

I wouldn't expose this in a separate class. I don't think that the route-names will be used outside of the controller for which they're used, so I'd specify them as private constants inside the controller where they're used.

_Originally posted by @fgheysels

MassimoC commented 5 years ago

on Constants.cs

        public static class RouteNames
        {
            // names of controller routes
            public static class v1
            {
                public const string GetCars = "Cars_GetCars";
                public const string GetCar = "Cars_GetCar";
                public const string GetCustomizations = "Customizations_GetCustomizations";
                public const string GetCustomization = "Customizations_GetCustomization";
                public const string CreateCustomization = "Customization_Create";
                public const string UpdateCustomizationIncremental = "Customizations_UpdateIncremental";
                public const string SellCustomization = "Customizations_Sell";
                public const string DeleteCustomization = "Customizations_DeleteCustomization";
            }
        }

These are used in the OpenApiTest.cs

pietersap commented 5 years ago

@fgheysels These changes to the constants are now merged into master. Do you agree we close this issue now, or do we want to discuss this further?

fgheysels commented 5 years ago

Can be closed.