Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally disable maybe-with-title #198

Closed
hkupty opened this issue Oct 17, 2019 · 2 comments
Closed

Conditionally disable maybe-with-title #198

hkupty opened this issue Oct 17, 2019 · 2 comments

Comments

@hkupty
Copy link

hkupty commented Oct 17, 2019

Hi, first of all thanks for spec-tools.

Currently, we have a setup where we generate json-schema/swagger documentation from spec the following way:

  • Every spec we declare that contains a {:name ...} attribute becomes a top-level schema;
  • When a top-level schema is used to compose another top-level schema such as (s/keys :req-un [::something]), it is declared as a $ref instead of inlining the definition.

This works fine for most specs. However, those that we declare as s/keys or s/map-of end up including a stringified name of itself when it doesn't have an explicit :name assigned.

To circumvent that, I've created this local version:

(defn transform-no-inferred-title [schema]
  (with-redefs [spec-tools.json-schema/maybe-with-title (fn [schm _] schm)]
   (jsc/transform schema)))

However, I think it'd be best if it was something like this:

(binding [spec-tools.json-schema/*infer-titles* false]
  (jsc/transform schema))

or

(jsc/transform schema {:infer-titles false})

Does this make sense?

Thanks in advance,
Henry Kupty

@ikitommi
Copy link
Member

Explicit option would be great. PR welcome.

@miikka
Copy link
Contributor

miikka commented May 5, 2020

Fixed in 0.10.2 by adding a new parameter to jsc/transform:

(jsc/transform schema {:infer-titles false})

@miikka miikka closed this as completed May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants