Git Product home page Git Product logo

http4k-openapi-annotations's Introduction

A proof-of-concept on modifying HTTP4k to allow null primitives in the Contract example, and not using nullability to decide required/optional properties. Also adds a new annotation to set description and required.

Fixes:

  1. null primitives in the Contract example: example = MyDto(firstName = null).
  2. Properties are required by default, opt-in for optional:
    • data class MyDto(firstName: String?, lastName: String?) -> "required": ["firstName", "lastName"] .
    • data class MyDto(@LifligOpenapiAnnotation(required = false) val firstName: String = "Michael", val lastName: String) -> "required": ["lastName"] .
    • Validation for optionals: fails when missing default value in class MyDto(@LifligOpenapiAnnotation(required = false) val firstName: String /* = "Michael" removed default*/) -> Exception .
  3. Non-jackson way to set description: @LifligOpenapiAnnotation(description = "Hello world") val myField .
  4. Correct schema for map-of-maps: mapOf("key" to mapOf("keyInner" to 5)) -> { "additionalProperties": { "additionalProperties": { "type": "number} } } .
  5. Correct schema for map-of-various: mapOf("key" to 1, "key2" to true) -> "additionalProperties": true .

TODO:

Stuff is prefixed with Liflig because it's my current employer. I just needed to separate code from the default http4k classes.


License: Apache 2.0. One file is copied from http4k with this license as well.

http4k-openapi-annotations's People

Contributors

krissrex avatar

Watchers

 avatar  avatar

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.