Code Monkey home page Code Monkey logo

Comments (5)

Wicpar avatar Wicpar commented on May 22, 2024 1

i will add such a mechanism as it is part of the standard.
until then you can use the new branch with the reworked models. null fields are now filtered when you use OpenAPIModel.build()
it will generate the appropriate hashmaps and remove empty and null values

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

you can specify it per request like this:

get<Unit, Response>(example = Response(...)) {

}

post<Unit, Response, Request>(
    exampleRequest = Request(...),
    exampleResponse = Response(...)
) { params, request ->

}

No mechanism exists yet to provide examples per model globally.

from ktor-openapi-generator.

SerVB avatar SerVB commented on May 22, 2024

Yeah, I use examples for methods. I'm not an experienced user of OpenAPI, so I don't know if examples of fields are also usually defined...

If yes, I want an opportunity to define them.

If no, just remove these "example" fields.

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

Added @WithExample in the latest commit.
SwagerUI doesn't handle it properly anyway.

        @WithExample
        class C(val l: @Clamp(0, 10) Long) : Base() {
            companion object: ExampleProvider<C> {
                override val example: C? = C(5)
            }
        }

or

        @WithExample(CExampleProvider::class)
        class C(val l: @Clamp(0, 10) Long) : Base()
...
        object CExampleProvider: ExampleProvider<C> {
                override val example: C? = C(5)
        }

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

implementation 'com.github.papsign:Ktor-OpenAPI-Generator:0.2-beta.0-experimental'

from ktor-openapi-generator.

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.