lutaml-jsonschema 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a31e1dc445c583474f10cf52d8468991193679ab428af9d46a0f760492373a2d
4
- data.tar.gz: 7dfe7fd154e030c64a9670b4d0c694b83e397fa8cff9d08d83222869bbfc1917
3
+ metadata.gz: 7489a2b5deaa74c751691afdf57939c046e29d6a853774462ce5587e05dcbcf3
4
+ data.tar.gz: fca882189c10df105bc30df80c5fe34cc0108ca82b87420e638170ec7a62d1e3
5
5
  SHA512:
6
- metadata.gz: 2a884595f8021d51474b547a1a06087aec67a5286250ba493f74657f8d9c7e3b8fdfc089c2cad865a90b9fceff984f877f1376c82adceb0928cfc33807b765c7
7
- data.tar.gz: f01cba83ee80adda6d6bc5ef16494fd23bbee7f0258759f4ea7ddc55305b9c535ab5c2ac4a0be15d8acc5fcbfef8d8f81b5a6655309501d3e2a9cde7f20bb475
6
+ metadata.gz: b27dd39b382a08e4fc1aa58ae1b9803ffbeee75fc3db6e3df0261871ce43d3aabfbe7cc863207b190c5a88e52212fca6f43acd40506d4f82088094a0ffd57ebf
7
+ data.tar.gz: d3af571ef80959e85a9c3e7ccaebb0a5e721d94348616a873edd25f6c488c596542ca0a8a836b94917a34bfdbc675cc2dc50f844995d7c5a055fc44348987926
data/.rubocop_todo.yml CHANGED
@@ -1,214 +1,43 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2026-05-06 16:54:24 UTC using RuboCop version 1.86.1.
3
+ # on 2026-05-07 10:44:46 UTC using RuboCop version 1.86.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 2
10
- # This cop supports safe autocorrection (--autocorrect).
11
- # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation.
12
- Bundler/OrderedGems:
13
- Exclude:
14
- - 'Gemfile'
15
-
16
- # Offense count: 2
17
- # This cop supports safe autocorrection (--autocorrect).
18
- # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation.
19
- Gemspec/OrderedDependencies:
20
- Exclude:
21
- - 'lutaml-jsonschema.gemspec'
22
-
23
9
  # Offense count: 1
24
10
  Gemspec/RequiredRubyVersion:
25
11
  Exclude:
26
12
  - 'lutaml-jsonschema.gemspec'
27
13
 
28
- # Offense count: 26
29
- # This cop supports safe autocorrection (--autocorrect).
30
- # Configuration parameters: EnforcedStyle, IndentationWidth.
31
- # SupportedStyles: with_first_argument, with_fixed_indentation
32
- Layout/ArgumentAlignment:
33
- Exclude:
34
- - 'lib/lutaml/jsonschema/cli.rb'
35
- - 'lib/lutaml/jsonschema/schema_set.rb'
36
- - 'lib/lutaml/jsonschema/spa/spa_builder.rb'
37
- - 'lib/lutaml/jsonschema/spa/vue_inlined_strategy.rb'
38
- - 'spec/lutaml/cli_spec.rb'
39
- - 'spec/lutaml/generator_spec.rb'
40
- - 'spec/lutaml/integration_spec.rb'
41
- - 'spec/lutaml/jsonschema_spec.rb'
42
- - 'spec/lutaml/schema_set_cross_ref_spec.rb'
43
- - 'spec/lutaml/schema_set_resolution_spec.rb'
44
- - 'spec/lutaml/spa_builder_spec.rb'
45
-
46
- # Offense count: 4
47
- # This cop supports safe autocorrection (--autocorrect).
48
- # Configuration parameters: EnforcedStyle, IndentationWidth.
49
- # SupportedStyles: with_first_element, with_fixed_indentation
50
- Layout/ArrayAlignment:
51
- Exclude:
52
- - 'lutaml-jsonschema.gemspec'
53
- - 'spec/lutaml/cli_spec.rb'
54
-
55
- # Offense count: 2
56
- # This cop supports safe autocorrection (--autocorrect).
57
- # Configuration parameters: IndentationWidth.
58
- Layout/AssignmentIndentation:
59
- Exclude:
60
- - 'lib/lutaml/jsonschema/schema.rb'
61
- - 'spec/lutaml/jsonschema_spec.rb'
62
-
63
- # Offense count: 16
14
+ # Offense count: 1
64
15
  # This cop supports safe autocorrection (--autocorrect).
65
16
  # Configuration parameters: EnforcedStyleAlignWith.
66
17
  # SupportedStylesAlignWith: either, start_of_block, start_of_line
67
18
  Layout/BlockAlignment:
68
19
  Exclude:
69
- - 'lib/lutaml/jsonschema/combiner.rb'
70
- - 'lib/lutaml/jsonschema/reference_resolver.rb'
71
- - 'lib/lutaml/jsonschema/schema_set.rb'
72
- - 'spec/lutaml/cli_spec.rb'
73
- - 'spec/lutaml/generator_spec.rb'
74
- - 'spec/lutaml/integration_spec.rb'
75
-
76
- # Offense count: 16
77
- # This cop supports safe autocorrection (--autocorrect).
78
- Layout/BlockEndNewline:
79
- Exclude:
80
- - 'lib/lutaml/jsonschema/combiner.rb'
81
- - 'lib/lutaml/jsonschema/reference_resolver.rb'
82
- - 'lib/lutaml/jsonschema/schema_set.rb'
83
- - 'spec/lutaml/cli_spec.rb'
84
- - 'spec/lutaml/generator_spec.rb'
85
- - 'spec/lutaml/integration_spec.rb'
86
-
87
- # Offense count: 4
88
- # This cop supports safe autocorrection (--autocorrect).
89
- Layout/ClosingParenthesisIndentation:
90
- Exclude:
91
- - 'lib/lutaml/jsonschema/reference_resolver.rb'
92
- - 'lib/lutaml/jsonschema/schema_set.rb'
93
- - 'spec/lutaml/integration_spec.rb'
94
-
95
- # Offense count: 1
96
- # This cop supports safe autocorrection (--autocorrect).
97
- Layout/ElseAlignment:
98
- Exclude:
99
- - 'lib/lutaml/jsonschema/reference_resolver.rb'
100
-
101
- # Offense count: 2
102
- # This cop supports safe autocorrection (--autocorrect).
103
- Layout/EmptyLinesAroundMethodBody:
104
- Exclude:
105
- - 'lib/lutaml/jsonschema/schema_set.rb'
106
-
107
- # Offense count: 1
108
- # This cop supports safe autocorrection (--autocorrect).
109
- # Configuration parameters: EnforcedStyleAlignWith.
110
- # SupportedStylesAlignWith: keyword, variable, start_of_line
111
- Layout/EndAlignment:
112
- Exclude:
113
- - 'lib/lutaml/jsonschema/reference_resolver.rb'
114
-
115
- # Offense count: 4
116
- # This cop supports safe autocorrection (--autocorrect).
117
- # Configuration parameters: EnforcedStyle, IndentationWidth.
118
- # SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
119
- Layout/FirstArgumentIndentation:
120
- Exclude:
121
- - 'lib/lutaml/jsonschema/reference_resolver.rb'
122
- - 'lib/lutaml/jsonschema/schema_set.rb'
123
- - 'spec/lutaml/integration_spec.rb'
124
-
125
- # Offense count: 32
126
- # This cop supports safe autocorrection (--autocorrect).
127
- # Configuration parameters: EnforcedStyle, IndentationWidth.
128
- # SupportedStyles: special_inside_parentheses, consistent, align_braces
129
- Layout/FirstHashElementIndentation:
130
- Exclude:
131
- - 'spec/lutaml/jsonschema_spec.rb'
132
- - 'spec/lutaml/schema_set_cross_ref_spec.rb'
133
-
134
- # Offense count: 34
135
- # This cop supports safe autocorrection (--autocorrect).
136
- # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
137
- # SupportedHashRocketStyles: key, separator, table
138
- # SupportedColonStyles: key, separator, table
139
- # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
140
- Layout/HashAlignment:
141
- Exclude:
142
- - 'lib/lutaml/jsonschema/schema.rb'
143
- - 'lib/lutaml/jsonschema/spa/spa_definition.rb'
144
- - 'lib/lutaml/jsonschema/spa/spa_document.rb'
145
- - 'lib/lutaml/jsonschema/spa/spa_schema.rb'
146
- - 'lutaml-jsonschema.gemspec'
147
- - 'spec/lutaml/jsonschema_spec.rb'
148
-
149
- # Offense count: 4
150
- # This cop supports safe autocorrection (--autocorrect).
151
- # Configuration parameters: EnforcedStyle.
152
- # SupportedStyles: normal, indented_internal_methods
153
- Layout/IndentationConsistency:
154
- Exclude:
155
- - 'lib/lutaml/jsonschema/combiner.rb'
156
-
157
- # Offense count: 35
158
- # This cop supports safe autocorrection (--autocorrect).
159
- # Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
160
- # SupportedStylesAlignWith: start_of_line, relative_to_receiver
161
- Layout/IndentationWidth:
162
- Exclude:
163
- - 'lib/lutaml/jsonschema/combiner.rb'
164
- - 'lib/lutaml/jsonschema/reference_resolver.rb'
165
- - 'lib/lutaml/jsonschema/schema_set.rb'
166
- - 'spec/lutaml/cli_spec.rb'
167
- - 'spec/lutaml/generator_spec.rb'
168
- - 'spec/lutaml/integration_spec.rb'
20
+ - 'lib/lutaml/jsonschema/spa/spa_builder.rb'
169
21
 
170
- # Offense count: 95
22
+ # Offense count: 28
171
23
  # This cop supports safe autocorrection (--autocorrect).
172
24
  # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
173
25
  # URISchemes: http, https
174
26
  Layout/LineLength:
175
- Enabled: false
176
-
177
- # Offense count: 1
178
- # This cop supports safe autocorrection (--autocorrect).
179
- Layout/MultilineBlockLayout:
180
27
  Exclude:
28
+ - 'lib/lutaml/jsonschema/base.rb'
29
+ - 'lib/lutaml/jsonschema/cli.rb'
181
30
  - 'lib/lutaml/jsonschema/combiner.rb'
182
-
183
- # Offense count: 3
184
- # This cop supports safe autocorrection (--autocorrect).
185
- # Configuration parameters: EnforcedStyle.
186
- # SupportedStyles: symmetrical, new_line, same_line
187
- Layout/MultilineMethodCallBraceLayout:
188
- Exclude:
189
- - 'lib/lutaml/jsonschema/reference_resolver.rb'
31
+ - 'lib/lutaml/jsonschema/schema.rb'
190
32
  - 'lib/lutaml/jsonschema/schema_set.rb'
33
+ - 'lib/lutaml/jsonschema/spa/spa_builder.rb'
34
+ - 'lib/lutaml/jsonschema/spa/vue_inlined_strategy.rb'
35
+ - 'lutaml-jsonschema.gemspec'
191
36
  - 'spec/lutaml/integration_spec.rb'
192
-
193
- # Offense count: 1
194
- # This cop supports safe autocorrection (--autocorrect).
195
- # Configuration parameters: EnforcedStyle, IndentationWidth.
196
- # SupportedStyles: aligned, indented, indented_relative_to_receiver
197
- Layout/MultilineMethodCallIndentation:
198
- Exclude:
199
- - 'spec/lutaml/integration_spec.rb'
200
-
201
- # Offense count: 1
202
- # This cop supports safe autocorrection (--autocorrect).
203
- Layout/RescueEnsureAlignment:
204
- Exclude:
205
- - 'lib/lutaml/jsonschema/schema_set.rb'
206
-
207
- # Offense count: 53
208
- # This cop supports safe autocorrection (--autocorrect).
209
- # Configuration parameters: AllowInHeredoc.
210
- Layout/TrailingWhitespace:
211
- Enabled: false
37
+ - 'spec/lutaml/jsonschema_spec.rb'
38
+ - 'spec/lutaml/schema_set_cross_ref_spec.rb'
39
+ - 'spec/lutaml/schema_set_resolution_spec.rb'
40
+ - 'spec/lutaml/spa_builder_spec.rb'
212
41
 
213
42
  # Offense count: 2
214
43
  # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
@@ -222,23 +51,7 @@ Lint/IneffectiveAccessModifier:
222
51
  Exclude:
223
52
  - 'lib/lutaml/jsonschema/schema_set.rb'
224
53
 
225
- # Offense count: 1
226
- # This cop supports safe autocorrection (--autocorrect).
227
- # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
228
- # NotImplementedExceptions: NotImplementedError
229
- Lint/UnusedMethodArgument:
230
- Exclude:
231
- - 'lib/lutaml/jsonschema/schema_set.rb'
232
-
233
- # Offense count: 3
234
- # This cop supports safe autocorrection (--autocorrect).
235
- Lint/UselessAssignment:
236
- Exclude:
237
- - 'lib/lutaml/jsonschema/spa/spa_builder.rb'
238
- - 'spec/lutaml/integration_spec.rb'
239
- - 'spec/lutaml/spa_builder_spec.rb'
240
-
241
- # Offense count: 13
54
+ # Offense count: 14
242
55
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
243
56
  Metrics/AbcSize:
244
57
  Exclude:
@@ -294,103 +107,8 @@ Naming/PredicateMethod:
294
107
  Exclude:
295
108
  - 'lib/lutaml/jsonschema/schema_set.rb'
296
109
 
297
- # Offense count: 1
298
- # This cop supports safe autocorrection (--autocorrect).
299
- Performance/ConstantRegexp:
300
- Exclude:
301
- - 'spec/lutaml/cli_spec.rb'
302
-
303
- # Offense count: 25
304
- # This cop supports safe autocorrection (--autocorrect).
305
- # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
306
- # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
307
- # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
308
- # FunctionalMethods: let, let!, subject, watch
309
- # AllowedMethods: lambda, proc, it
310
- Style/BlockDelimiters:
311
- Exclude:
312
- - 'lib/lutaml/jsonschema/reference_resolver.rb'
313
- - 'lib/lutaml/jsonschema/schema_set.rb'
314
- - 'spec/lutaml/cli_spec.rb'
315
- - 'spec/lutaml/generator_spec.rb'
316
- - 'spec/lutaml/integration_spec.rb'
317
-
318
110
  # Offense count: 2
319
111
  # This cop supports unsafe autocorrection (--autocorrect-all).
320
112
  Style/IdenticalConditionalBranches:
321
113
  Exclude:
322
114
  - 'spec/lutaml/spa_builder_spec.rb'
323
-
324
- # Offense count: 6
325
- # This cop supports safe autocorrection (--autocorrect).
326
- Style/MultilineIfModifier:
327
- Exclude:
328
- - 'lib/lutaml/jsonschema/schema_set.rb'
329
-
330
- # Offense count: 2
331
- # This cop supports safe autocorrection (--autocorrect).
332
- Style/MultilineTernaryOperator:
333
- Exclude:
334
- - 'lib/lutaml/jsonschema/reference_resolver.rb'
335
-
336
- # Offense count: 1
337
- # This cop supports safe autocorrection (--autocorrect).
338
- Style/RedundantBegin:
339
- Exclude:
340
- - 'lib/lutaml/jsonschema/schema_set.rb'
341
-
342
- # Offense count: 1
343
- # This cop supports safe autocorrection (--autocorrect).
344
- # Configuration parameters: AllowMultipleReturnValues.
345
- Style/RedundantReturn:
346
- Exclude:
347
- - 'lib/lutaml/jsonschema/schema_set.rb'
348
-
349
- # Offense count: 1
350
- # This cop supports safe autocorrection (--autocorrect).
351
- Style/RescueModifier:
352
- Exclude:
353
- - 'lib/lutaml/jsonschema/schema_set.rb'
354
-
355
- # Offense count: 1
356
- # This cop supports safe autocorrection (--autocorrect).
357
- # Configuration parameters: EnforcedStyle.
358
- # SupportedStyles: implicit, explicit
359
- Style/RescueStandardError:
360
- Exclude:
361
- - 'lib/lutaml/jsonschema/schema_set.rb'
362
-
363
- # Offense count: 35
364
- # This cop supports safe autocorrection (--autocorrect).
365
- # Configuration parameters: EnforcedStyleForMultiline.
366
- # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
367
- Style/TrailingCommaInArguments:
368
- Exclude:
369
- - 'lib/lutaml/jsonschema/combiner.rb'
370
- - 'lib/lutaml/jsonschema/configuration.rb'
371
- - 'lib/lutaml/jsonschema/schema.rb'
372
- - 'lib/lutaml/jsonschema/spa/spa_builder.rb'
373
- - 'spec/lutaml/generator_spec.rb'
374
- - 'spec/lutaml/integration_spec.rb'
375
- - 'spec/lutaml/jsonschema_spec.rb'
376
- - 'spec/lutaml/schema_set_cross_ref_spec.rb'
377
- - 'spec/lutaml/schema_set_resolution_spec.rb'
378
- - 'spec/lutaml/spa_builder_spec.rb'
379
- - 'spec/lutaml/spa_spec.rb'
380
-
381
- # Offense count: 4
382
- # This cop supports safe autocorrection (--autocorrect).
383
- # Configuration parameters: EnforcedStyleForMultiline.
384
- # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
385
- Style/TrailingCommaInArrayLiteral:
386
- Exclude:
387
- - 'spec/lutaml/jsonschema_spec.rb'
388
-
389
- # Offense count: 23
390
- # This cop supports safe autocorrection (--autocorrect).
391
- # Configuration parameters: EnforcedStyleForMultiline.
392
- # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
393
- Style/TrailingCommaInHashLiteral:
394
- Exclude:
395
- - 'spec/lutaml/jsonschema_spec.rb'
396
- - 'spec/lutaml/schema_set_cross_ref_spec.rb'
data/frontend/src/App.vue CHANGED
@@ -34,9 +34,32 @@ onMounted(() => {
34
34
  uiStore.updateResolvedTheme()
35
35
  }
36
36
 
37
+ handleHashNavigation()
38
+
37
39
  document.addEventListener('keydown', handleKeydown)
40
+ window.addEventListener('hashchange', handleHashNavigation)
38
41
  })
39
42
 
43
+ function handleHashNavigation() {
44
+ const hash = window.location.hash.slice(1)
45
+ if (!hash) return
46
+
47
+ const parts = hash.split('/')
48
+ if (parts.length >= 1 && schemaStore.schemas.length > 0) {
49
+ const schemaName = decodeURIComponent(parts[0])
50
+ schemaStore.selectSchema(schemaName)
51
+
52
+ if (parts.length >= 2) {
53
+ const target = decodeURIComponent(parts[1])
54
+ if (target.startsWith('def-')) {
55
+ schemaStore.selectDefinition(target.slice(4))
56
+ } else if (target.startsWith('prop-')) {
57
+ schemaStore.selectProperty(target.slice(5))
58
+ }
59
+ }
60
+ }
61
+ }
62
+
40
63
  function handleKeydown(e: KeyboardEvent) {
41
64
  if (e.key === '/' && !isInputFocused()) {
42
65
  e.preventDefault()
@@ -0,0 +1,41 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { renderInlineMarkdown } from '../composables/useMarkdownLite'
3
+
4
+ describe('renderInlineMarkdown', () => {
5
+ it('returns empty for empty string', () => {
6
+ expect(renderInlineMarkdown('')).toBe('')
7
+ })
8
+
9
+ it('renders bold text', () => {
10
+ expect(renderInlineMarkdown('**bold**')).toBe('<strong>bold</strong>')
11
+ })
12
+
13
+ it('renders italic text', () => {
14
+ expect(renderInlineMarkdown('*italic*')).toBe('<em>italic</em>')
15
+ })
16
+
17
+ it('renders inline code', () => {
18
+ expect(renderInlineMarkdown('`code`')).toBe('<code class="md-code">code</code>')
19
+ })
20
+
21
+ it('renders links', () => {
22
+ const result = renderInlineMarkdown('[click](https://example.com)')
23
+ expect(result).toContain('<a href="https://example.com"')
24
+ expect(result).toContain('class="md-link"')
25
+ expect(result).toContain('>click</a>')
26
+ })
27
+
28
+ it('escapes HTML', () => {
29
+ expect(renderInlineMarkdown('<b>no</b>')).toBe('&lt;b&gt;no&lt;/b&gt;')
30
+ })
31
+
32
+ it('returns plain text unchanged', () => {
33
+ expect(renderInlineMarkdown('hello world')).toBe('hello world')
34
+ })
35
+
36
+ it('handles mixed formatting', () => {
37
+ const result = renderInlineMarkdown('Use `method` for **special** cases.')
38
+ expect(result).toContain('<code class="md-code">method</code>')
39
+ expect(result).toContain('<strong>special</strong>')
40
+ })
41
+ })
@@ -38,8 +38,16 @@ describe('primaryType', () => {
38
38
  })
39
39
 
40
40
  describe('displayType', () => {
41
- it('shows array<itemsType> for arrays', () => {
42
- expect(displayType(prop({ type: 'array', itemsType: 'string' }))).toBe('array<string>')
41
+ it('shows "array of X" for arrays', () => {
42
+ expect(displayType(prop({ type: 'array', itemsType: 'string' }))).toBe('array of string')
43
+ })
44
+
45
+ it('shows resolved title for $ref props', () => {
46
+ expect(displayType(prop({ type: 'object', ref: '#/definitions/Addr' }), 'Address')).toBe('Address')
47
+ })
48
+
49
+ it('ignores resolved title when no ref', () => {
50
+ expect(displayType(prop({ type: 'object' }), 'Address')).toBe('object')
43
51
  })
44
52
 
45
53
  it('shows type (format) when format is set', () => {
@@ -225,24 +233,34 @@ describe('hasConstraints', () => {
225
233
  })
226
234
 
227
235
  describe('humanizeConstraints', () => {
228
- it('returns string range constraint', () => {
236
+ it('returns string range constraint with bracket notation', () => {
229
237
  const chips = humanizeConstraints(prop({ type: 'string', minLength: 1, maxLength: 100 }))
230
- expect(chips).toEqual([{ label: '1..100 characters' }])
238
+ expect(chips).toEqual([{ label: '[ 1 .. 100 ] characters' }])
231
239
  })
232
240
 
233
- it('returns numeric >= and <= constraints', () => {
241
+ it('returns non-empty for minLength === 1', () => {
242
+ const chips = humanizeConstraints(prop({ type: 'string', minLength: 1 }))
243
+ expect(chips).toEqual([{ label: 'non-empty' }])
244
+ })
245
+
246
+ it('returns numeric range constraint with bracket notation', () => {
234
247
  const chips = humanizeConstraints(prop({ type: 'integer', minimum: 0, maximum: 100 }))
235
- expect(chips.map(c => c.label)).toEqual(['>= 0', '<= 100'])
248
+ expect(chips.map(c => c.label)).toEqual(['[ 0 .. 100 ]'])
236
249
  })
237
250
 
238
- it('returns exclusive bounds with > and <', () => {
251
+ it('returns exclusive bounds combined as range', () => {
239
252
  const chips = humanizeConstraints(prop({ type: 'number', exclusiveMinimum: 0, exclusiveMaximum: 100 }))
240
- expect(chips.map(c => c.label)).toEqual(['> 0', '< 100'])
253
+ expect(chips.map(c => c.label)).toEqual(['( 0 .. 100 )'])
254
+ })
255
+
256
+ it('returns inclusive range combined with exclusive modifier', () => {
257
+ const chips = humanizeConstraints(prop({ type: 'integer', minimum: 0, maximum: 100, exclusiveMinimum: 0 }))
258
+ expect(chips.map(c => c.label)).toEqual(['( 0 .. 100 ]'])
241
259
  })
242
260
 
243
- it('returns array range constraint', () => {
261
+ it('returns array range constraint with bracket notation', () => {
244
262
  const chips = humanizeConstraints(prop({ type: 'array', minItems: 1, maxItems: 10 }))
245
- expect(chips).toEqual([{ label: '1..10 items' }])
263
+ expect(chips).toEqual([{ label: '[ 1 .. 10 ] items' }])
246
264
  })
247
265
 
248
266
  it('returns unique for uniqueItems', () => {
@@ -275,6 +293,26 @@ describe('humanizeConstraints', () => {
275
293
  expect(chips).toEqual([])
276
294
  })
277
295
 
296
+ it('returns "non-empty" for minLength 1', () => {
297
+ const chips = humanizeConstraints(prop({ type: 'string', minLength: 1 }))
298
+ expect(chips.map(c => c.label)).toEqual(['non-empty'])
299
+ })
300
+
301
+ it('returns "= N characters" when min equals max', () => {
302
+ const chips = humanizeConstraints(prop({ type: 'string', minLength: 10, maxLength: 10 }))
303
+ expect(chips.map(c => c.label)).toEqual(['= 10 characters'])
304
+ })
305
+
306
+ it('returns "= N items" when minItems equals maxItems', () => {
307
+ const chips = humanizeConstraints(prop({ type: 'array', minItems: 3, maxItems: 3 }))
308
+ expect(chips.map(c => c.label)).toEqual(['= 3 items'])
309
+ })
310
+
311
+ it('returns decimal places for small multipleOf', () => {
312
+ const chips = humanizeConstraints(prop({ type: 'number', multipleOf: 0.01 }))
313
+ expect(chips.map(c => c.label)).toEqual(['decimal places <= 2'])
314
+ })
315
+
278
316
  it('returns contentMediaType and contentEncoding', () => {
279
317
  const chips = humanizeConstraints(prop({ contentMediaType: 'text/html', contentEncoding: 'base64' }))
280
318
  expect(chips.map(c => c.label)).toEqual(['content-type: text/html', 'encoding: base64'])