Giter VIP home page Giter VIP logo

Comments (3)

joshbooker avatar joshbooker commented on July 26, 2024

Since this is primarily for tooling to use as 'friendly name' it's not necessary that summary value be unique.

If you're not inclined to make this change, perhaps then please consider at least dropping 'entity in entityset' from the summary value. Or, omit summary and use description instead as tools will fall back to operationId if summary doesn't exist.

edit: Nevermind the below OperationFilter works well for my needs.

Thanks again for all your hard work!

from swashbuckle.odata.

joshbooker avatar joshbooker commented on July 26, 2024

Was able to make this change using OperationFilter like so:

internal class ChangeSummaryInOperationFilter : IOperationFilter
{
    public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
    {
        //RENAME
        //reverse from 'Orders_Get' to 'Get Orders'
        string str = $"{string.Join(" ", operation.operationId.Split('_').Reverse())}";
        //build dict of rename replacements to be made
        string s = "Put=Replace;Post=Create;Patch=Update";
        var dictRename = s.Split(';').Select(x => x.Split('=')).ToDictionary(x => x[0], x => x[1]);
        //make rename replacements
        string newstr = dictRename.Aggregate(str, (current, value) => current.Replace(value.Key, value.Value));

        //SINGULARIZE
        //if has parameters other than query
        if (operation.parameters != null &! operation.parameters.All(p => p.@in == "query"))//.Any(p => p.@in == "path" || p.@in == "body"))
        {   //should prolly reuse pServ rather than new it up repeatedly(?)
            var pServ = new System.Data.Entity.Infrastructure.Pluralization.EnglishPluralizationService();
            newstr = $"{newstr.Split(' ')[0]} {pServ.Singularize(newstr.Split(' ')[1])}";
        }

        //set description and summary
        operation.description = operation.summary;
        operation.summary = newstr;
    }
}

Looks like this in swagger ui:

northwindsummary

And works great with Azure Logic App tooling:

northwindsummarylogicapp

from swashbuckle.odata.

 avatar commented on July 26, 2024

Woops, missed the edit. Looks like the OperationFilter meets your needs. Closing. Thanks.

from swashbuckle.odata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.