Coder Social home page Coder Social logo

Compojure-api roadmap about compojure-api HOT 3 CLOSED

metosin avatar metosin commented on August 29, 2024
Compojure-api roadmap

from compojure-api.

Comments (3)

ikitommi avatar ikitommi commented on August 29, 2024

did a spike to refactor internals for 5 & 8. Stuff found in here:
https://github.com/metosin/compojure-api/compare/context-star

notable changes:

  • breaking: meta-data handlers collects parameters in 2.0 format, meta/src-coerce! removed in favour of meta/src-coerce-param!. Will break client restructuring, but those should be easy to fix (need migration guide).
  • context* allows setting the meta-datas to mid-routes. Route-peeler accumulates all meta-data to endpoints (via deep-merge). does not currently rewrite the code itself, so works in the route-peeling phase for the swagger datas.
  • separate pipeline to accumulate the runtime meta-datas to endpoint via lexically scoped meta/+compojure-api-meta+. This would not work over defroutes*.
  • TODO: figure out how to combine the two accumulations (route-peeling time & runtime). Will do some extra spiking on this. Will not push anything into master before things clear out. Would work ok if we approve that parameter validations can't inherit from mid-routes to endpoints.
    (context* "/context/:kikka" []
      :summary "summary inherited from context" ; works ok
      :path-params [kikka :- s/Str] ; currently enforced here 
      :query-params [kukka :- s/Str] ; currently enforced here too
      (GET* "/api" []
        ; does not generate any code for parameter validation as meta-data is passed in at runtime (not at compile-time)
        (ok {:kikka kikka
             :kukka kukka})))

from compojure-api.

ikitommi avatar ikitommi commented on August 29, 2024

... context* seems to work ok'ish. Does not cumulate lists & sets. Could...

(fact "accumulation in context*"
  (let [metas (atom nil)]
    (defapi api
      (swaggered +name+
        (context* "/:id" []
          :path-params [id :- String]
          :tags [:api]
          :summary "jeah"
          (GET* "/:di/ping" []
            :tags [:ipa]
            :path-params [di :- String]
            :query-params [foo :- s/Int]
            (reset! metas +compojure-api-meta+)
            (ok [id di foo])))))

    (fact "all but lists & sequences get accumulated"
      (let [[status body] (get* api "/kikka/kukka/ping" {:foo 123})]
        status => 200
        body => ["kikka" "kukka" 123]
        @metas => {:parameters {:path {:id String
                                       :di String
                                       s/Keyword s/Any}
                                :query {:foo s/Int
                                        s/Keyword s/Any}}
                   :summary "jeah"
                   :tags #{:ipa}}))))

from compojure-api.

ikitommi avatar ikitommi commented on August 29, 2024

https://github.com/metosin/compojure-api/tree/swagger2routes

from compojure-api.

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.