Giter Club home page Giter Club logo

Comments (12)

daviddenton avatar daviddenton commented on May 18, 2024

Is this mitigated by the operationId PR? If so, can we close it? πŸ˜€

from http4k.

danschultz avatar danschultz commented on May 18, 2024

@daviddenton operationId only helps customize the naming of endpoints. This feature is to customize the naming of model types (request and response types). Would be great if naming was inferred by the class name, with a way to override it if needed.

from http4k.

daviddenton avatar daviddenton commented on May 18, 2024

We definitely can't use the classname, because the API only takes requests and response objects and I think we'd like to keep that simplicity. Underneath, we could possibly use a custom header that was set in the HTTP message to set the value if required. Would that work?

from http4k.

danschultz avatar danschultz commented on May 18, 2024

What do you think of having some wrapper or metadata type to define additional info about the response objects. To keep the API simple, maybe we could have a helper to create a β€œmetadata” object from a Response instance.

from http4k.

daviddenton avatar daviddenton commented on May 18, 2024

I'm not against the idea - we can provide it as an option which is invisible to the user. The main complexity that I can see is with the JsonSchema class. The generation of the "definitionId" is embedded within the recursive call to the JSON schema generation. Need to work out the best way to embed.

Note that either approach would only end up with you being able to name the "top level objects" - ie. the main request and response bodies. The sub objects would still be automatically named based on the hashcode of the JSON object.

from http4k.

danschultz avatar danschultz commented on May 18, 2024

Note that either approach would only end up with you being able to name the "top level objects" - ie. the main request and response bodies. The sub objects would still be automatically named based on the hashcode of the JSON object.

Missed that, thanks for pointing that out. I think from a DX perspective, folks would expect the model types get automatically named down the object graph.

from http4k.

daviddenton avatar daviddenton commented on May 18, 2024

@danschultz I've put a fix in for this using a meta object as you suggested. Take a look at https://github.com/http4k/http4k/blob/master/http4k-contract/src/test/kotlin/org/http4k/contract/ContractRendererContract.kt and let me know if that API would work out for you?

from http4k.

daviddenton avatar daviddenton commented on May 18, 2024

Will be released in 3.14.0

from http4k.

danschultz avatar danschultz commented on May 18, 2024

Works for me! Thanks @daviddenton!

from http4k.

daviddenton avatar daviddenton commented on May 18, 2024

Excellent. Closing to release.

from http4k.

mindscratch avatar mindscratch commented on May 18, 2024

@danschultz where is the name for the items in "definitions" being set? For "receiving" I see I can set a definitionId, but is there a way to do that for the returning? For example I have something like this currently:

returning(
   "submitted successfully" to Response(CREATED).with(Body.auto<MyResponse>().toLens() of MyResponse("success!")))

from http4k.

mindscratch avatar mindscratch commented on May 18, 2024

Oh I see...

returning(
   ResponseMeta("submitted successfully", Response(CREATED).with(Body.auto<MyResponse>().toLens() of MyResponse("success!")), "my-response")
)

...where my-response is the name I gave to the type that'll show up in the "definitions" section of the JSON schema.

from http4k.

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.