mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 13:44:54 +03:00
fix: improve code
This commit is contained in:
parent
532c30e88c
commit
9fdcdfb049
|
@ -196,7 +196,7 @@ export class SchemaModel {
|
|||
const title =
|
||||
isNamedDefinition(variant.$ref) && !merged.title
|
||||
? JsonPointer.baseName(variant.$ref)
|
||||
: (merged.const && JSON.stringify(merged.const)) || merged.title;
|
||||
: `${(merged.title || '')}${(merged.const && JSON.stringify(merged.const)) || ''}`;
|
||||
|
||||
const schema = new SchemaModel(
|
||||
parser,
|
||||
|
|
|
@ -227,6 +227,19 @@ describe('Utils', () => {
|
|||
expect(isPrimitiveType(schema)).toEqual(false);
|
||||
});
|
||||
|
||||
it('should return true for array contains array of strings', () => {
|
||||
const schema = {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(isPrimitiveType(schema)).toEqual(true);
|
||||
});
|
||||
|
||||
it('Should return false for array of string which include the null value', () => {
|
||||
const schema = {
|
||||
type: ['object', 'string', 'null'],
|
||||
|
|
|
@ -126,7 +126,7 @@ export function isPrimitiveType(schema: OpenAPISchema, type: string | string[] |
|
|||
}
|
||||
|
||||
if (schema.items !== undefined && (type === 'array' || (isArray && type?.includes('array')))) {
|
||||
isPrimitive = false;
|
||||
isPrimitive = isPrimitiveType(schema.items, schema.items.type);
|
||||
}
|
||||
|
||||
return isPrimitive;
|
||||
|
|
Loading…
Reference in New Issue
Block a user