pb33f / libopenapi

libopenapi is a fully featured, high performance OpenAPI 3.1, 3.0 and Swagger parser, library, validator and toolkit for golang applications.
https://pb33f.io/libopenapi/
Other
482 stars 64 forks source link

feat: add server variable extensions #326

Closed geffersonFerraz closed 2 months ago

geffersonFerraz commented 2 months ago

Allow to use server variable extension:

    envVar := &v3.ServerVariable{
        Enum:       []string{"api.mycompany.com", "api-preprod.mycompany.com"},
        Extensions: orderedmap.New[string, *yaml.Node](),
    }
    envVar.Description = "Environment to use"
    envVar.Default = "api.mycompany.com"
    envTransforms := []map[string]interface{}{
        {
            "type": "translate",
            "translations": []map[string]string{
                {"from": "prod", "to": "api.mycompany.com"},
                {"from": "pre-prod", "to": "api-preprod.mycompany.com"},
            },
        },
    }
    envVar.Extensions.Set("x-transforms", createExtension(envTransforms))
    server.Variables.Set("env", envVar)

    mergedSpecA.Model.Servers = append(mergedSpecA.Model.Servers, server)
codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.64%. Comparing base (49a2921) to head (d26b0d2). Report is 22 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #326 +/- ## ======================================= Coverage 99.63% 99.64% ======================================= Files 164 164 Lines 16586 16674 +88 ======================================= + Hits 16526 16614 +88 Misses 55 55 Partials 5 5 ``` | [Flag](https://app.codecov.io/gh/pb33f/libopenapi/pull/326/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pb33f) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/pb33f/libopenapi/pull/326/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pb33f) | `99.64% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pb33f#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

daveshanley commented 2 months ago

Two lines to cover and it's good to go.

daveshanley commented 2 months ago

Fix the tests and I can add this in!