Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .spectral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,11 @@ rules:
function: pattern
functionOptions:
notMatch: 'string'

schema-name-length-must-be-short:
description: "Schema name must not be too long to support client generation. Current limitation comes from Ruby packages which uses tar and has a limit of 100 characters."
given: $.components.schemas[*]~
then:
function: length
functionOptions:
max: 95
7 changes: 7 additions & 0 deletions TestSpecs/schema-name-length-must-be-short-invalid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
openapi: 3.0.1
info:
title: dummy
components:
schemas:
VeryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName:
type: object
7 changes: 7 additions & 0 deletions TestSpecs/schema-name-length-must-be-short-valid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
openapi: 3.0.1
info:
title: dummy
components:
schemas:
ShortName:
type: object
4 changes: 3 additions & 1 deletion test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ $tests = @(
@{ rule = "schema-ids-must-have-alphanumeric-characters-only"; expectError = $false; filename = "schema-ids-must-have-alphanumeric-characters-only-valid.yaml" },
@{ rule = "schema-ids-must-have-alphanumeric-characters-only"; expectError = $true; filename = "schema-ids-must-have-alphanumeric-characters-only-invalid.yaml" },
@{ rule = "schema-object-must-have-a-type"; expectError = $false; filename = "schema-object-must-have-a-type-valid.yaml" },
@{ rule = "schema-object-must-have-a-type"; expectError = $true; filename = "schema-object-must-have-a-type-invalid.yaml" }
@{ rule = "schema-object-must-have-a-type"; expectError = $true; filename = "schema-object-must-have-a-type-invalid.yaml" },
@{ rule = "schema-name-length-must-be-short"; expectError = $false; filename = "schema-name-length-must-be-short-valid.yaml" },
@{ rule = "schema-name-length-must-be-short"; expectError = $true; filename = "schema-name-length-must-be-short-invalid.yaml" }
)

$fileCount = Get-ChildItem (Join-Path $PSScriptRoot "TestSpecs") | Measure-Object | Select-Object -ExpandProperty Count
Expand Down