• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

onmoon / openapi-server-bundle / 15880807807

25 Jun 2025 03:38PM UTC coverage: 80.585% (-0.5%) from 81.095%
15880807807

Pull #196

github

web-flow
Merge 5d3727a9f into c35fba5f2
Pull Request #196: Fix minimum versions install

7 of 21 new or added lines in 4 files covered. (33.33%)

1 existing line in 1 file now uncovered.

1378 of 1710 relevant lines covered (80.58%)

3.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.33
/src/Exception/CannotParseOpenApi.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace OnMoon\OpenApiServerBundle\Exception;
6

7
use function sprintf;
8

9
final class CannotParseOpenApi extends OpenApiError
10
{
11
    /** @param array{method:string,url:string,path:string} $context */
12
    public static function becauseNoOperationIdSpecified(array $context): self
13
    {
14
        return new self(
1✔
15
            sprintf(
1✔
16
                'No operationId specified for operation: "%s" of path: "%s" in specification file: "%s".',
1✔
17
                $context['method'],
1✔
18
                $context['url'],
1✔
19
                $context['path']
1✔
20
            )
1✔
21
        );
1✔
22
    }
23

24
    public static function becausePropertyIsNotScheme(): self
25
    {
26
        return new self('Property is not scheme');
×
27
    }
28

29
    public static function becauseUnknownReferenceFound(string $name): self
30
    {
31
        return new self(sprintf('Component "%s does not exist"', $name));
×
32
    }
33

34
    /** @param array{method:string,url:string,path:string} $context */
35
    public static function becauseDuplicateOperationId(string $id, array $context): self
36
    {
37
        return new self(
1✔
38
            sprintf(
1✔
39
                'Operation ID "%s" already taken for operation: "%s" of path: "%s" in specification file: "%s".',
1✔
40
                $id,
1✔
41
                $context['method'],
1✔
42
                $context['url'],
1✔
43
                $context['path']
1✔
44
            )
1✔
45
        );
1✔
46
    }
47

48
    /** @param array{location:string,method:string,url:string,path:string} $context */
49
    public static function becauseRootIsNotObject(
50
        array $context,
51
        bool $isArray
52
    ): self {
53
        $moreInfo = '';
1✔
54
        if ($isArray) {
1✔
55
            $moreInfo = '(array as root is insecure, see https://haacked.com/archive/2009/06/25/json-hijacking.aspx/) ';
1✔
56
        }
57

58
        return new self(
1✔
59
            sprintf(
1✔
60
                'Only object is allowed as root in %s ' . $moreInfo .
1✔
61
                'for operation: "%s" of path: "%s" in specification file: "%s".',
1✔
62
                $context['location'],
1✔
63
                $context['method'],
1✔
64
                $context['url'],
1✔
65
                $context['path']
1✔
66
            )
1✔
67
        );
1✔
68
    }
69

70
    /** @param array{location:string,method:string,url:string,path:string} $context */
71
    public static function becauseOnlyScalarAreAllowed(string $propertyName, array $context): self
72
    {
73
        return new self(
1✔
74
            sprintf(
1✔
75
                'Cannot generate property for DTO class, property "%s" is not scalar in %s for operation: "%s" of path: "%s" in specification file: "%s".',
1✔
76
                $propertyName,
1✔
77
                $context['location'],
1✔
78
                $context['method'],
1✔
79
                $context['url'],
1✔
80
                $context['path']
1✔
81
            )
1✔
82
        );
1✔
83
    }
84

85
    /** @param array{location:string,method:string,url:string,path:string} $context */
86
    public static function becauseOpenapi31TypesNotSupported(string $propertyName, array $context): self
87
    {
NEW
88
        return new self(
×
NEW
89
            sprintf(
×
NEW
90
                'Cannot generate property for DTO class, property "%s" has multiple types in %s for operation: "%s" of path: "%s" in specification file: "%s".',
×
NEW
91
                $propertyName,
×
NEW
92
                $context['location'],
×
NEW
93
                $context['method'],
×
NEW
94
                $context['url'],
×
NEW
95
                $context['path']
×
NEW
96
            )
×
NEW
97
        );
×
98
    }
99

100
    /** @param array{location:string,method:string,url:string,path:string} $context */
101
    public static function becauseArrayIsNotDescribed(string $propertyName, array $context): self
102
    {
103
        return new self(
1✔
104
            sprintf(
1✔
105
                'Cannot generate property for DTO class, property "%s" is array without items description in %s for operation: "%s" of path: "%s" in specification file: "%s".',
1✔
106
                $propertyName,
1✔
107
                $context['location'],
1✔
108
                $context['method'],
1✔
109
                $context['url'],
1✔
110
                $context['path']
1✔
111
            )
1✔
112
        );
1✔
113
    }
114

115
    /** @param array{location:string,method:string,url:string,path:string} $context */
116
    public static function becauseTypeNotSupported(string $propertyName, string $type, array $context): self
117
    {
118
        return new self(
1✔
119
            sprintf(
1✔
120
                'Cannot generate property for DTO class, property "%s" type "%s" is not supported in %s for operation: "%s" of path: "%s" in specification file: "%s".',
1✔
121
                $propertyName,
1✔
122
                $type,
1✔
123
                $context['location'],
1✔
124
                $context['method'],
1✔
125
                $context['url'],
1✔
126
                $context['path']
1✔
127
            )
1✔
128
        );
1✔
129
    }
130

131
    public static function becauseUnknownType(string $name): self
132
    {
133
        return new self(sprintf('Class "%s" does not exist', $name));
×
134
    }
135

136
    public static function becauseNotFQCN(string $name): self
137
    {
138
        return new self(sprintf('Class "%s" should have fully qualified name', $name));
×
139
    }
140
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc