This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-25
Channels
- # bangalore-clj (5)
- # beginners (225)
- # boot (36)
- # cider (1)
- # clara (2)
- # cljsjs (1)
- # clojure (76)
- # clojure-belgium (1)
- # clojure-conj (1)
- # clojure-india (4)
- # clojure-italy (5)
- # clojure-korea (1)
- # clojure-russia (22)
- # clojure-spec (35)
- # clojure-uk (52)
- # clojurescript (67)
- # community-development (17)
- # core-logic (2)
- # cursive (2)
- # datascript (28)
- # datomic (44)
- # emacs (1)
- # funcool (3)
- # hoplon (14)
- # lein-figwheel (2)
- # leiningen (2)
- # luminus (3)
- # midje (3)
- # mount (2)
- # nyc (2)
- # om (54)
- # om-next (1)
- # onyx (30)
- # re-frame (57)
- # reagent (19)
- # ring-swagger (23)
- # slack-help (10)
- # spacemacs (2)
- # specter (1)
- # vim (23)
if I have hyphens in my schema keys, like {:foo-tastic s/Int} is it possible to configure Ring Swagger to do some kind of property name conversion from foo-tastic to foo_tastic?
I'm wondering if its worth the trouble to use hyphens in schema keywords as they are causing trouble when converted to JSON.. but its the Clojure convention
there is a helper function ring.swagger.swagger2/transform-operations
to walk through the endpoints before passing into ring-swagger. Still, you would have to do it on three places: 1) after parsing the body 2) when returning the body c) for the docs. Did that once, was not worth it. But, could be done. Example of a ring-swagger doc transformation: https://github.com/metosin/ring-swagger#transforming-the-swagger-spec
thanks.. so do you just use underscores in your schemas if you're exposing some APIs ?
depends on the project, have tried ‘em all I guess 🙂 Hyphens work with javascript too btw. Or are they illegal in the JSON spec?
yeah it works.. but i'd prefer the users of API to be able to use it like obj.property_name instead of obj["property-name"] .. im not sure of JSON spec
in ring swagger spec there's the :schema map entry.. does it have to be a symbol like MySchema or can it be just inline map ? I suppose inline should work ?
trying a different route, transforming the schema before i pass it to ring swagger.. using this to transform the schema: https://github.com/gfredericks/schema-bijections/blob/master/README.md
i can transform the schema quite easily.. but for some reason :references ends up with my schemas, but there is no :properties
im not sure how the resolutions to :definitions works, but my transformed schema has :name in its metadata.. i suppose its required
@sammikko yes, the $ref is taken from the name. Haven’t uses the bijections lib, looks cool. There is also https://github.com/metosin/schema-tools which retains the schema meta-data.
cool.. i think i found my problem.. i converted the keys in my schema map from keywords to strings and that didnt work in ring swagger.. im not sure if thats even supported in schema 🙂
awesome! Schema allows String keys, ring-swagger might not be happy with those. Please write an issue if you need that.
there is a lovely use-case for Schema walkers in the schema-viz lib, like https://github.com/metosin/schema-viz/blob/master/src/schema_viz/core.clj#L81-L92
oh yeah, we actually used schema-viz too 🙂 it works but we ran into trouble when running on a headless server: No X11 DISPLAY variable was set, but this program performed an operation which requires it., compiling:(rhizome/viz.clj:27:1)
yeah, its this one: https://github.com/ztellman/rhizome/issues/10