@@ -0,0 +1,3 @@ | |||||
{:paths ["src/main/clj"] | |||||
:deps {org.clojure/clojure {:mvn/version "1.10.3"} | |||||
clj-commons/clj-yaml {:mvn/version "0.7.0"}}} |
@@ -1 +0,0 @@ |
@@ -0,0 +1,43 @@ | |||||
(ns gen.core | |||||
(:require [clojure.string :as str] | |||||
[clj-yaml.core :as yaml] | |||||
[scan.lang.php.laravel5.scan :as laravel5])) | |||||
(def | |||||
^{} | |||||
run | |||||
(fn [args] | |||||
(laravel5/routes (first args)) | |||||
#_(println | |||||
(yaml/generate-string | |||||
{"openapi" "3.0.0" | |||||
:info | |||||
{:version 1 | |||||
:title "thing" | |||||
:license | |||||
{:name "MIT"}} | |||||
:servers | |||||
[{:url "thing"}] | |||||
:paths | |||||
{"/pets" | |||||
{:get | |||||
{:parameters | |||||
[{:name "limit" | |||||
:in "query" | |||||
:description "aaaaaaaa" | |||||
:required false | |||||
:schema | |||||
{:type "integer" | |||||
:format "int32"}}]}} | |||||
"/lists" | |||||
{:get | |||||
{:responses | |||||
{"200" | |||||
{:description "ok"}}}}} | |||||
:spec {:lorem "ipsum" :thing true}} | |||||
:dumper-options {:indent 2 | |||||
:indicator-indent 1 | |||||
:flow-style :block})))) | |||||
(defn -main [& argv] | |||||
(prn (run argv))) |
@@ -0,0 +1,18 @@ | |||||
(ns scan.lang.php.laravel5.scan | |||||
(:require [clojure.string :as str])) | |||||
(def | |||||
^{} | |||||
routes | |||||
(fn [project-path] | |||||
(let [route-file (str project-path "/routes/web.php")] | |||||
(map (fn [hit] | |||||
(let [[_ verb raw-params] hit | |||||
params (map (fn [e] (str/trim (str/escape e {\' ""}))) (str/split raw-params #",")) | |||||
[route ctl] params] | |||||
{:verb verb | |||||
:route route | |||||
:ctl ctl})) | |||||
(re-seq | |||||
#"router->(.*)\((.*)\)" | |||||
(slurp route-file)))))) |