Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Generating realistic example values

オープン
#403 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
clojure, openapi
領域
api, documentation

調査の方向性

まず、Prismatic Schema の定義がどのように Swagger UI のサンプル値になるかを追跡し、次にその経路を test.check を使用して説明されているカスタムジェネレーターと比較します。スキーマが制約を満たす現実的な値を提供でき、それらの値が生成された Swagger UI の例に表示されれば、issue は完了です。

索引モデルが issue の本文から書いたものです。

説明

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!

主要言語
Clojure
スター
1.1k
フォーク
145
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

metosin/compojure-api のほかの issue

metosin/compojure-api の issue をすべて見る

似ている issue

Clojure の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。