Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
522 views
in Technique[技术] by (71.8m points)

asp.net core - Why Swagger is not picking up the summary of an ApplicationService method in ABP Framework?

I have the following application service method.

public class MyAppService : AsyncCrudAppService<Entity, Dto, Guid, GetAllRequest, CreateRequest, UpdateRequest, GetRequest, DeleteRequest>, IMyAppService
{
    /// <summary>
    /// Return cities associated with zip code
    /// </summary>
    /// <param name="zipCode">Zip code to search. If null all cities are returned.</param>
    /// <returns>Cities associated with zip code.</returns>
    /// <exception cref="EntityNotFoundException">If zip code is provided but no associated city is found</exception>
    /// <response code="404">If no city with zip code found</response>
    [ProducesResponseType(StatusCodes.Status200OK)]
    [ProducesResponseType(StatusCodes.Status404NotFound)]
    public async Task<GetCitiesByZipCodeResponse> GetCitiesByZipCode(int? zipCode = null)
    {
        ...
    }
}

Even though I have a summary describing what the endpoint does, it is not displayed in swagger. What is the right way to add rich information to Swagger about app service methods?

It did pick up the effect of ProducesResponseType(StatusCodes.Status404NotFound) and showing 404 as possible response though.

Swagger for GetCitiesByZipCode

question from:https://stackoverflow.com/questions/65871756/why-swagger-is-not-picking-up-the-summary-of-an-applicationservice-method-in-abp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

AppServices are automatically converted to Controllers. But your custom Swagger attributes are stripped off. If you have a such requirement, then create a new MyContoller and call your AppService methods inside the Controller. And disable remote service function for your Appservice with the following attribute

[RemoteService(IsEnabled = false)] 

https://docs.abp.io/en/abp/latest/API/Auto-API-Controllers#remoteservice-attribute


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...