Giter VIP home page Giter VIP logo

Comments (25)

sheepdreamofandroids avatar sheepdreamofandroids commented on May 22, 2024 3

Laying traps for unsuspecting developers so you can get PR's of them. Genius!

I'm not exactly bristling with free time myself, but let me look at it.

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

Hi,

Thank you for this issue, i know this would happen eventually.
Currently only primitive types are implemented since i use the jackson parser as a quick fix, there are no standard parsers for the query parameter standards as far as i know, and the query parameter standards are quite wonky as well.
Here is the spec:
https://swagger.io/docs/specification/serialization/
Here is the relevant function to change the behavior:
https://github.com/papsign/Ktor-OpenAPI-Generator/blob/master/src/main/kotlin/com/papsign/ktor/openapigen/route/OpenAPIRoute.kt#L74

I am quite busy on another project at the moment, feel free to make a pull request, but once finished i can work on it.

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

Haha.
I found a library that seems to decode RFC 6570 templates
damnhandy/Handy-URI-Templates#54
I'll see if i can implement it rapidly.
I wanted to avoid implementing the entire RFC from scratch, but if a library gets the job done the modifications are a matter of a few hours at most.

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

Good and bad news...
I can't use the library as is, but i can frankenstein in the proper parsing behavior.

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

After all implementing it from scratch seems a lot faster now.
I think i can get it done by 15:00 GMT+2

from ktor-openapi-generator.

sheepdreamofandroids avatar sheepdreamofandroids commented on May 22, 2024

Do you intend to let us specify how parameters have to be encoded? Or will you just accept anything the client throws at you?

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

You will have to specify, defaults being according to the openapi spec, but i will try to make it parse anything you throw at it.
Some collisions are possible, they will be caught during startup.

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

I Have finished implementing the primitives:
implementation 'com.github.papsign:Ktor-OpenAPI-Generator:experimental-parameters-a35e1a0143-1'
i will be adding collections and object support very soon

from ktor-openapi-generator.

sheepdreamofandroids avatar sheepdreamofandroids commented on May 22, 2024

Wow, you're on fire!

I'll build your branch and see how that works for my usecase. It's really simple, I just need a list of longs, so that shouldn't be a problem. I'll let you know asap.

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

I am working on the lists and arrays, it's a little trickier than primitives.

from ktor-openapi-generator.

sheepdreamofandroids avatar sheepdreamofandroids commented on May 22, 2024

Just a brainfart. Shouldn't RFC 6570 be implemented as a format for kotlinx-serialization?

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

nope, ktor doesn't support RFC 6570 parsing, and no library is made to properly parse individual parameters...

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

lists have been added, you can build the latest changes on jitpack

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

objects are next, but i think i will limit the support to data classes in the beginning...
It should not be too complicated to extend afterwards.
Once that is done i'll clean the whole mess.

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

Deep object support has been added. It does not support empty indices for arrays.
Path param objects and form objects are still missing.
Appropriate errors are thrown on startup if anything is not implemented.

from ktor-openapi-generator.

sheepdreamofandroids avatar sheepdreamofandroids commented on May 22, 2024

Hi, I've been trying to use your branch but it's not yet working for me.
Firstly I think you need a 'maven' or 'maven-publish' plugin in gradle to actually generate a pom. The jitpack artifact is only a jar without transitive dependencies. I'm not good with gradle so I'm not sure that is how to fix it.
After adding those dependencies manually (reflections and swagger.js) I get a swagger interface, but my List is still seen as a singular Long.
Possibly I'm missing some dependencies.

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

If the main library works the test branch should work as well...
I'm not quite sure how jitpack works but i am able to use it without declaring those other dependencies.
here is the config:

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    implementation "ch.qos.logback:logback-classic:$logback_version"
    implementation "io.ktor:ktor-server-core:$ktor_version"
    implementation "io.ktor:ktor-server-host-common:$ktor_version"
    implementation "io.ktor:ktor-metrics:$ktor_version"
    implementation "io.ktor:ktor-server-sessions:$ktor_version"
    implementation "io.ktor:ktor-server-netty:$ktor_version"
    implementation "io.ktor:ktor-jackson:$ktor_version"


    implementation 'com.github.papsign:Ktor-OpenAPI-Generator:experimental-parameters-SNAPSHOT'
}

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

@sheepdreamofandroids It's over, it's done...
The code is now up to spec and in a clean and maintainable state.
I am merging the branch soon after integration testing.

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

I have merged the changes into master and made a release.

from ktor-openapi-generator.

sheepdreamofandroids avatar sheepdreamofandroids commented on May 22, 2024

I'm trying to use this in my own project and it just doesn't work.
At the same time I created a testcase within your project which works flawlessly.
I've not been able to figure out exactly what is the difference. Mostly because I've been in meetings way more than programming.
Just to let you know why I didn't react yet.

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

Alright.
On my side we successfully updated the dependency simply by setting the version to the new release in the project configuration.
Make sure you are also up to date with the kotlin plugin.

from ktor-openapi-generator.

sheepdreamofandroids avatar sheepdreamofandroids commented on May 22, 2024

Hi, I had weird effects. First everything worked as expected except for the array parameter and the fact that I couldn't debug my project in Intellij, it would freeze completely.
Now I just upgraded to the latest kotlin plugin (1.3.70) and did the same with the ktor dependency (1.3.2) and now nothing really works anymore.
I'm assuming that is because of the different ktor versions. Is there a particular reason you stick with 1.2.6? I'm quite new to using ktor, so if I'm upgrading too fast, I really like to know.

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

No reason the ktor version is not updated.
Try to use the release version as dependencies, snapshots might break regularly.
I'll update the ktor version asap.

from ktor-openapi-generator.

Wicpar avatar Wicpar commented on May 22, 2024

updated version. https://github.com/papsign/Ktor-OpenAPI-Generator/releases/tag/0.1-beta.2

from ktor-openapi-generator.

sheepdreamofandroids avatar sheepdreamofandroids commented on May 22, 2024

Thanks so much for the help. Now it works.
The real culprit though was the fact that we are using gson for JSON serialization instead of jackson.

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.