Comments (12)
Is this mitigated by the operationId PR? If so, can we close it? π
from http4k.
@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.
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.
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.
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.
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.
@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.
Will be released in 3.14.0
from http4k.
Works for me! Thanks @daviddenton!
from http4k.
Excellent. Closing to release.
from http4k.
@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.
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)
- Use RequestContexts for providing a User Principal with org.http4k.contract.security.Security HOT 1
- Integrate Jackson Module Kogera HOT 5
- Extracting access token from custom AccessToken response fails HOT 2
- Remove all extraneous options for server creation
- Jackson does not honour serialisation of Enums when they are used as Map keys HOT 1
- Support multi value query parameters in ApiGatewayV2LambdaFunction (http4k-serverless/lambda)
- Documentation error? - Lambda version HOT 2
- For a request with matching if-none-match header the response lacks the etag header HOT 1
- Header values in quotes lose their quotes HOT 2
- Client code works with OkHttp, fails with Java HTTP HOT 1
- Maven POM for http4k-format-jackson-xml is invalid: jackson-dataformat-xml is missing a version HOT 1
- Deserialisation exception from GraphQLResponse.from
- OpenApi 3 schema generation is flawed for Maps HOT 5
- Java8HttpClient causes SignatureDoesNotMatch exception on S3Bucket.copyObject() request HOT 11
- Support WsHandler symmetry HOT 1
- Http4kWebDriver does not work on Windows due to path issues. HOT 3
- Add BiDiLensSpec defaulted with factory method HOT 5
- Error when parsing AWS lambda event from S3 bucket HOT 3
- Can't define the file download spec in OpenAPI HOT 3
- brew tap should not install jdk when I already have it HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http4k.