Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for naming of methods when generating interfaces by endpoint #176

Closed
Noblix opened this issue Oct 5, 2023 · 2 comments · Fixed by #181
Closed

Allow for naming of methods when generating interfaces by endpoint #176

Noblix opened this issue Oct 5, 2023 · 2 comments · Fixed by #181
Assignees
Labels
enhancement New feature, bug fix, or request

Comments

@Noblix
Copy link
Contributor

Noblix commented Oct 5, 2023

Is your feature request related to a problem?
I think it would be nice if it were possible to choose naming for methods when interfaces are generated ByEndpoint. Right now it is only possible to customize method names when all endpoints are in a single interface. When doing it for a single interface the {operationName} is a requirement, but I do not think this should be a requirement since there will only be one method in each interface.

Describe the solution you'd like
Example of how this could work:

{
    "openApiPath": "./openapi.json",
    "namespace": "Your.Namespace.Of.Choice.GeneratedCode",
    "multipleInterfaces": "ByEndpoint",
    "operationNameTemplate": "ExecuteAsync" // Default is Execute
}

The .refitter file above results in the following code:

/// <summary>
/// Update an existing pet
/// </summary>
public partial interface IUpdatePetEndpoint
{
    /// <summary>
    /// Update an existing pet by Id
    /// </summary>
    [Put("/pet")]
    Task<Pet> Execute([Body] Pet body);
}

/// <summary>
/// Add a new pet to the store
/// </summary>
public partial interface IAddPetEndpoint
{
    /// <summary>
    /// Add a new pet to the store
    /// </summary>
    [Post("/pet")]
    Task<Pet> Execute([Body] Pet body);
}

...
@Noblix Noblix added the enhancement New feature, bug fix, or request label Oct 5, 2023
@christianhelle
Copy link
Owner

@all-contributors please add @Noblix for ideas

@allcontributors
Copy link
Contributor

@christianhelle

I've put up a pull request to add @Noblix! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, bug fix, or request
Projects
None yet
2 participants