Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Generating realistic example values

Aperta
#403 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
clojure, openapi
Ambito
api, documentation

Direzione di ricerca

Inizia tracciando come le definizioni di Prismatic Schema diventano valori di esempio per Swagger UI, quindi confronta questo percorso con il generatore personalizzato descritto usando test.check. L’issue è completa quando uno schema può fornire valori realistici che soddisfano i vincoli e tali valori compaiono negli esempi Swagger UI generati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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!

Lingua principale
Clojure
Stelle
1.1k
Fork
145
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di metosin/compojure-api

Tutte le issue di metosin/compojure-api

Issue simili

Altre issue su Clojure

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.