Skip to content

Commit

Permalink
fix(28833): ensure examples is an array
Browse files Browse the repository at this point in the history
  • Loading branch information
vanch3d committed Dec 11, 2024
1 parent 6ae85d0 commit 33a79ce
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const GENERATE_DATA_MODELS = (short = false, title?: string): RJSFSchema
type: 'string',
title: short ? 'First String' : 'firstName',
default: 'Chuck',
examples: 'firstName',
examples: ['firstName'],
},
lastName: {
type: 'string',
Expand All @@ -40,11 +40,11 @@ export const GENERATE_DATA_MODELS = (short = false, title?: string): RJSFSchema
subItems: {
type: 'object',
title: 'subItems',
examples: 'subItems',
examples: ['subItems'],

properties: {
name: {
examples: 'name',
examples: ['name'],
type: 'string',
title: 'name',
default: 'Default name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('PropertyItem', () => {

it('should render examples properly', () => {
cy.mountWithProviders(
<PropertyItem property={{ ...MOCK_PROPERTY, examples: 'this is a sample' }} isDraggable={false} hasExamples />
<PropertyItem property={{ ...MOCK_PROPERTY, examples: ['this is a sample'] }} isDraggable={false} hasExamples />
)

cy.getByAriaLabel('Property').should('have.attr', 'data-type', 'object')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('reducerSchemaExamples', () => {
expect.objectContaining({
properties: expect.objectContaining({
age: {
examples: 1,
examples: [1],
title: 'Age',
type: 'integer',
},
Expand All @@ -125,13 +125,13 @@ describe('reducerSchemaExamples', () => {
nestedObject: expect.objectContaining({
properties: expect.objectContaining({
age: {
examples: 100,
examples: [100],
title: 'Age',
type: 'integer',
},
name: {
default: 'Default name',
examples: 'test2',
examples: ['test2'],
type: 'string',
},
}),
Expand All @@ -156,7 +156,7 @@ describe('payloadToSchema', () => {
'test/topic1': {
properties: {
age: {
examples: 1,
examples: [1],
type: 'integer',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const reducerSchemaExamples = (state: RJSFSchema, event: JsonNode) =>
})
.with(P._, ([allStates, examples]) => {
if (!examples) return allStates
return { ...allStates, examples: examples }
return { ...allStates, examples: [examples] }
})
.exhaustive()

Expand Down

0 comments on commit 33a79ce

Please sign in to comment.