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

Generating realistic example values #403

Open
mikera opened this issue Nov 19, 2018 · 0 comments
Open

Generating realistic example values #403

mikera opened this issue Nov 19, 2018 · 0 comments

Comments

@mikera
Copy link

mikera commented Nov 19, 2018

Library Version(s)

1.1.11

Problem

I'm experimenting with compojure-api for documenting a new set of APIs with Prismatic Schema. It;s working well so far, though I have one issue which is not obvious how to resolve - how to generate realistic example values for an input / output schema.

Currently I get Example Values in the swagger UI like this:

{
  "name": "string",
  "description": "string",
  "type": "assetClass1",
  "ownerID": "string"
  "dateCreated": "2018-11-19T01:25:04.282Z",
}

In this case, I need ownerID to be a 64 character hex string which satisfies a custom valid-user-id? predicate, which defined in Schema as something like:

(s/defschema UserID
  (s/constrained s/Str valid-user-id? "Valid User ID"))

However it's not clear how to get compojure-api to generate valid values which satisfy the constraint (The value "string" doesn't....) and display these to the user in the Swagger UI.

Is there a way to do this? Ideally I would like to be able to specify a custom generator for the schema, which I build easily enough with test.check but how do I get that to be reflected in the Swagger UI?

Any help much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant