mirror of
https://github.com/ilyakooo0/compaREST.git
synced 2024-10-05 19:37:12 +03:00
Fixed ProdCons value pairs in report (#112)
* Fixed ProdCons value pairs in report * normalizeProdConsOrientation -> orientProdCons * Applied fix to PathFragmentsDontMatch
This commit is contained in:
parent
a501f6ed41
commit
d50b2ba645
8
fourmolu.yaml
Normal file
8
fourmolu.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
indentation: 2
|
||||
comma-style: leading # for lists, tuples etc. - can also be 'trailing'
|
||||
record-brace-space: true # rec {x = 1} vs. rec{x = 1}
|
||||
indent-wheres: true # 'false' means save space by only half-indenting the 'where' keyword
|
||||
diff-friendly-import-export: false # 'false' uses Ormolu-style lists
|
||||
respectful: true # don't be too opinionated about newlines etc.
|
||||
haddock-style: single-line # '--' vs. '{-'
|
||||
newlines-between-decls: 1 # number of newlines between top-level declarations
|
@ -18,6 +18,7 @@ module OpenAPI.Checker.Subtree
|
||||
, CompatFormula'
|
||||
, SemanticCompatFormula
|
||||
, ProdCons (..)
|
||||
, orientProdCons
|
||||
, swapProdCons
|
||||
, runCompatFormula
|
||||
, issueAt
|
||||
@ -110,6 +111,10 @@ data ProdCons a = ProdCons
|
||||
}
|
||||
deriving stock (Eq, Ord, Show, Functor, Foldable, Traversable)
|
||||
|
||||
orientProdCons :: Orientation -> ProdCons x -> ProdCons x
|
||||
orientProdCons Forward x = x
|
||||
orientProdCons Backward (ProdCons p c) = ProdCons c p
|
||||
|
||||
swapProdCons
|
||||
:: SwapEnvRoles xs
|
||||
=> (HList xs -> ProdCons x -> CompatFormula' q AnIssue r a)
|
||||
|
@ -66,7 +66,7 @@ instance Issuable 'PathFragmentLevel where
|
||||
ParamStyleMismatch
|
||||
| -- | One of schemas not presented
|
||||
ParamSchemaMismatch
|
||||
| PathFragmentsDontMatch Text Text
|
||||
| PathFragmentsDontMatch (ProdCons Text)
|
||||
deriving stock (Eq, Ord, Show)
|
||||
issueIsUnsupported _ = False
|
||||
describeIssue _ ParamNameMismatch = para "The path fragments don't match."
|
||||
@ -77,7 +77,8 @@ instance Issuable 'PathFragmentLevel where
|
||||
describeIssue _ ParamPlaceIncompatible = para "Parameters in incompatible locations."
|
||||
describeIssue _ ParamStyleMismatch = para "Different parameter styles (encodings)."
|
||||
describeIssue _ ParamSchemaMismatch = para "Expected a schema, but didn't find one."
|
||||
describeIssue _ (PathFragmentsDontMatch e a) = para $ "Parameter changed from " <> code e <> " to " <> code a <> "."
|
||||
describeIssue ori (PathFragmentsDontMatch (orientProdCons ori -> ProdCons e a)) =
|
||||
para $ "Parameter changed from " <> code e <> " to " <> code a <> "."
|
||||
|
||||
instance Behavable 'PathFragmentLevel 'SchemaLevel where
|
||||
data Behave 'PathFragmentLevel 'SchemaLevel
|
||||
|
@ -74,6 +74,6 @@ instance Subtree PathFragmentParam where
|
||||
checkSemanticCompatibility _ beh (ProdCons (extract -> StaticPath x) (extract -> StaticPath y)) =
|
||||
if x == y
|
||||
then pure ()
|
||||
else issueAt beh (PathFragmentsDontMatch x y)
|
||||
else issueAt beh (PathFragmentsDontMatch (ProdCons x y))
|
||||
checkSemanticCompatibility env beh prodCons = do
|
||||
checkCompatibility beh env (tracedPathFragmentParam <$> prodCons)
|
||||
|
@ -94,26 +94,32 @@ instance Issuable 'TypedSchemaLevel where
|
||||
describeIssue Backward (NoMatchingEnum v) = para "The following enum value has been removed:" <> showJSONValue v
|
||||
describeIssue Forward (NoMatchingMaximum b) = para $ "Upper bound has been added:" <> showBound b <> "."
|
||||
describeIssue Backward (NoMatchingMaximum b) = para $ "Upper bound has been removed:" <> showBound b <> "."
|
||||
describeIssue _ (MatchingMaximumWeak (ProdCons p c)) = para $ "Upper bound changed from " <> showBound p <> " to " <> showBound c <> "."
|
||||
describeIssue ori (MatchingMaximumWeak (orientProdCons ori -> ProdCons p c)) =
|
||||
para $ "Upper bound changed from " <> showBound p <> " to " <> showBound c <> "."
|
||||
describeIssue Forward (NoMatchingMinimum b) = para $ "Lower bound has been added: " <> showBound b <> "."
|
||||
describeIssue Backward (NoMatchingMinimum b) = para $ "Lower bound has been removed: " <> showBound b <> "."
|
||||
describeIssue _ (MatchingMinimumWeak (ProdCons p c)) = para $ "Lower bound changed from " <> showBound p <> " to " <> showBound c <> "."
|
||||
describeIssue ori (MatchingMinimumWeak (orientProdCons ori -> ProdCons p c)) =
|
||||
para $ "Lower bound changed from " <> showBound p <> " to " <> showBound c <> "."
|
||||
describeIssue Forward (NoMatchingMultipleOf n) = para $ "Value is now a multiple of " <> show' n <> "."
|
||||
describeIssue Backward (NoMatchingMultipleOf n) = para $ "Value is no longer a multiple of " <> show' n <> "."
|
||||
describeIssue _ (MatchingMultipleOfWeak (ProdCons p c)) = para $ "Value changed from being a multiple of " <> show' p <> " to being a multiple of " <> show' c <> "."
|
||||
describeIssue ori (MatchingMultipleOfWeak (orientProdCons ori -> ProdCons p c)) =
|
||||
para $ "Value changed from being a multiple of " <> show' p <> " to being a multiple of " <> show' c <> "."
|
||||
describeIssue Forward (NoMatchingFormat f) = para $ "Format added: " <> code f <> "."
|
||||
describeIssue Backward (NoMatchingFormat f) = para $ "Format removed: " <> code f <> "."
|
||||
describeIssue Forward (NoMatchingMaxLength n) = para $ "Maximum length added: " <> show' n <> "."
|
||||
describeIssue Backward (NoMatchingMaxLength n) = para $ "Maximum length removed: " <> show' n <> "."
|
||||
describeIssue _ (MatchingMaxLengthWeak (ProdCons p c)) = para $ "Maximum length of the string changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue ori (MatchingMaxLengthWeak (orientProdCons ori -> ProdCons p c)) =
|
||||
para $ "Maximum length of the string changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue Forward (NoMatchingMinLength n) = para $ "Minimum length of the string added: " <> show' n <> "."
|
||||
describeIssue Backward (NoMatchingMinLength n) = para $ "Minimum length of the string removed: " <> show' n <> "."
|
||||
describeIssue _ (MatchingMinLengthWeak (ProdCons p c)) = para $ "Minimum length of the string changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue ori (MatchingMinLengthWeak (orientProdCons ori -> ProdCons p c)) =
|
||||
para $ "Minimum length of the string changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue Forward (NoMatchingPattern p) = para "Pattern (regular expression) added: " <> codeBlock p
|
||||
describeIssue Backward (NoMatchingPattern p) = para "Pattern (regular expression) removed: " <> codeBlock p
|
||||
describeIssue Forward NoMatchingItems = para "Array item schema has been added."
|
||||
describeIssue Backward NoMatchingItems = para "Array item schema has been removed."
|
||||
describeIssue _ (TupleItemsLengthChanged (ProdCons p c)) = para $ "Tuple length changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue ori (TupleItemsLengthChanged (orientProdCons ori -> ProdCons p c)) =
|
||||
para $ "Tuple length changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue Forward ArrayToTuple = para "The array is now explicitly defined as a tuple."
|
||||
describeIssue Backward ArrayToTuple = para "The array is no longer explicitly defined as a tuple."
|
||||
describeIssue Forward TupleToArray = para "The array is no longer explicitly defined as a tuple."
|
||||
@ -122,10 +128,12 @@ instance Issuable 'TypedSchemaLevel where
|
||||
describeIssue Backward NoMatchingTupleItems = para "The array is no longer explicitly defined as a tuple."
|
||||
describeIssue Forward (NoMatchingMaxItems n) = para $ "Maximum length of the array has been added " <> show' n <> "."
|
||||
describeIssue Backward (NoMatchingMaxItems n) = para $ "Maximum length of the array has been removed " <> show' n <> "."
|
||||
describeIssue _ (MatchingMaxItemsWeak (ProdCons p c)) = para $ "Maximum length of the array changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue ori (MatchingMaxItemsWeak (orientProdCons ori -> ProdCons p c)) =
|
||||
para $ "Maximum length of the array changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue Forward (NoMatchingMinItems n) = para $ "Minimum length of the array added: " <> show' n <> "."
|
||||
describeIssue Backward (NoMatchingMinItems n) = para $ "Minimum length of the array removed: " <> show' n <> "."
|
||||
describeIssue _ (MatchingMinItemsWeak (ProdCons p c)) = para $ "Minimum length of the array changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue ori (MatchingMinItemsWeak (orientProdCons ori -> ProdCons p c)) =
|
||||
para $ "Minimum length of the array changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue Forward NoMatchingUniqueItems = para "Items are now required to be unique."
|
||||
describeIssue Backward NoMatchingUniqueItems = para "Items are no longer required to be unique."
|
||||
describeIssue Forward NoMatchingProperties = para "Property added."
|
||||
@ -134,17 +142,20 @@ instance Issuable 'TypedSchemaLevel where
|
||||
describeIssue Backward NoAdditionalProperties = para "Additional properties have been added."
|
||||
describeIssue Forward (NoMatchingMaxProperties n) = para $ "Maximum number of properties has been added: " <> show' n <> "."
|
||||
describeIssue Backward (NoMatchingMaxProperties n) = para $ "Maximum number of properties has been removed: " <> show' n <> "."
|
||||
describeIssue _ (MatchingMaxPropertiesWeak (ProdCons p c)) = para $ "Maximum number of properties has changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue ori (MatchingMaxPropertiesWeak (orientProdCons ori -> ProdCons p c)) =
|
||||
para $ "Maximum number of properties has changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue Forward (NoMatchingMinProperties n) = para $ "Minimum number of properties added: " <> show' n <> "."
|
||||
describeIssue Backward (NoMatchingMinProperties n) = para $ "Minimum number of properties removed: " <> show' n <> "."
|
||||
describeIssue _ (MatchingMinPropertiesWeak (ProdCons p c)) = para $ "Minimum number of properties has changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue ori (MatchingMinPropertiesWeak (orientProdCons ori -> ProdCons p c)) =
|
||||
para $ "Minimum number of properties has changed from " <> show' p <> " to " <> show' c <> "."
|
||||
describeIssue _ (NoMatchingCondition mPart conds) =
|
||||
para
|
||||
(case mPart of
|
||||
Nothing -> "Could not verify that the following conditions hold (please file a bug if you see this):"
|
||||
Just locPart ->
|
||||
"In cases where " <> showPartition locPart
|
||||
<> " – could not verify that the following conditions hold (please file a bug if you see this):")
|
||||
( case mPart of
|
||||
Nothing -> "Could not verify that the following conditions hold (please file a bug if you see this):"
|
||||
Just locPart ->
|
||||
"In cases where " <> showPartition locPart
|
||||
<> " – could not verify that the following conditions hold (please file a bug if you see this):"
|
||||
)
|
||||
<> bulletList ((\(SomeCondition c) -> showCondition c) <$> conds)
|
||||
describeIssue Forward TypeBecomesEmpty = para "The type has been removed."
|
||||
describeIssue Backward TypeBecomesEmpty = para "The type has been added."
|
||||
|
56
test/golden/common/random-example/a.yaml
Normal file
56
test/golden/common/random-example/a.yaml
Normal file
@ -0,0 +1,56 @@
|
||||
openapi: "3.0.0"
|
||||
info:
|
||||
version: 1.0.0
|
||||
title: Swagger Petstore
|
||||
license:
|
||||
name: MIT
|
||||
servers:
|
||||
- url: https://example.com
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
parameters:
|
||||
- name: limit
|
||||
in: query
|
||||
required: false
|
||||
schema:
|
||||
type: integer
|
||||
maximum: 20
|
||||
responses:
|
||||
"200":
|
||||
description: ""
|
||||
headers:
|
||||
x-next:
|
||||
schema:
|
||||
type: string
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pets"
|
||||
post:
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pet"
|
||||
responses:
|
||||
"201":
|
||||
description: ""
|
||||
components:
|
||||
schemas:
|
||||
Pet:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
minLength: 3
|
||||
maxLength: 10
|
||||
Pets:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Pet"
|
58
test/golden/common/random-example/b.yaml
Normal file
58
test/golden/common/random-example/b.yaml
Normal file
@ -0,0 +1,58 @@
|
||||
openapi: "3.0.0"
|
||||
info:
|
||||
version: 1.1.0
|
||||
title: Swagger Petstore
|
||||
license:
|
||||
name: MIT
|
||||
servers:
|
||||
- url: https://example.com
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
parameters:
|
||||
- name: limit
|
||||
in: query
|
||||
required: false
|
||||
schema:
|
||||
type: integer
|
||||
maximum: 30
|
||||
responses:
|
||||
"200":
|
||||
description: ""
|
||||
headers:
|
||||
x-next:
|
||||
schema:
|
||||
type: string
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pets"
|
||||
post:
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Pet"
|
||||
responses:
|
||||
"201":
|
||||
description: ""
|
||||
components:
|
||||
schemas:
|
||||
Pet:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 15
|
||||
weight:
|
||||
type: integer
|
||||
Pets:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Pet"
|
71
test/golden/common/random-example/report.md
Normal file
71
test/golden/common/random-example/report.md
Normal file
@ -0,0 +1,71 @@
|
||||
# Summary
|
||||
|
||||
| [⚠️ Breaking changes](#breaking-changes) | [🙆 Non-breaking changes](#non-breaking-changes) | 🤷 Unsupported feature changes |
|
||||
|------------------------------------------|-------------------------------------------------|-------------------------------|
|
||||
| 5 | 6 | 0 |
|
||||
|
||||
# <span id="breaking-changes"></span>⚠️ Breaking changes
|
||||
|
||||
## **GET** /pets
|
||||
|
||||
### 📱⬅️ JSON Response – 200
|
||||
|
||||
#### `$[*].name(String)`
|
||||
|
||||
1. Maximum length of the string changed from 10 to 15.
|
||||
|
||||
2. Minimum length of the string changed from 3 to 1.
|
||||
|
||||
## **POST** /pets
|
||||
|
||||
### 📱➡️ JSON Request
|
||||
|
||||
#### `$.weight`
|
||||
|
||||
1. Values are now limited to the following types:
|
||||
|
||||
- Number
|
||||
|
||||
2. The property was previously implicitly described by the catch-all
|
||||
"additional properties" case. It is now explicitly defined.
|
||||
|
||||
#### `$.weight(Number)`
|
||||
|
||||
Value is now a multiple of 1.0.
|
||||
|
||||
# <span id="non-breaking-changes"></span>🙆 Non-breaking changes
|
||||
|
||||
## **GET** /pets
|
||||
|
||||
### Parameter limit
|
||||
|
||||
#### JSON Schema
|
||||
|
||||
##### `$(Number)`
|
||||
|
||||
Upper bound changed from 20.0 inclusive to 30.0 inclusive.
|
||||
|
||||
### 📱⬅️ JSON Response – 200
|
||||
|
||||
#### `$[*].weight`
|
||||
|
||||
1. Values are now limited to the following types:
|
||||
|
||||
- Number
|
||||
|
||||
2. The property was previously implicitly described by the catch-all
|
||||
"additional properties" case. It is now explicitly defined.
|
||||
|
||||
#### `$[*].weight(Number)`
|
||||
|
||||
Value is now a multiple of 1.0.
|
||||
|
||||
## **POST** /pets
|
||||
|
||||
### 📱➡️ JSON Request
|
||||
|
||||
#### `$.name(String)`
|
||||
|
||||
1. Maximum length of the string changed from 10 to 15.
|
||||
|
||||
2. Minimum length of the string changed from 3 to 1.
|
48
test/golden/common/random-example/trace-tree.yaml
Normal file
48
test/golden/common/random-example/trace-tree.yaml
Normal file
@ -0,0 +1,48 @@
|
||||
breakingChanges:
|
||||
AtPath "/pets":
|
||||
InOperation GetMethod:
|
||||
WithStatusCode 200:
|
||||
ResponsePayload:
|
||||
PayloadSchema:
|
||||
OfType Array:
|
||||
InItems:
|
||||
OfType Object:
|
||||
InProperty "name":
|
||||
OfType String:
|
||||
- MatchingMaxLengthWeak (ProdCons {producer = 15, consumer = 10})
|
||||
- MatchingMinLengthWeak (ProdCons {producer = 1, consumer = 3})
|
||||
InOperation PostMethod:
|
||||
InRequest:
|
||||
InPayload:
|
||||
PayloadSchema:
|
||||
OfType Object:
|
||||
InProperty "weight":
|
||||
- TypesRestricted [Number]
|
||||
- AdditionalToProperty
|
||||
- OfType Number: NoMatchingMultipleOf 1.0
|
||||
nonBreakingChanges:
|
||||
AtPath "/pets":
|
||||
InOperation GetMethod:
|
||||
WithStatusCode 200:
|
||||
ResponsePayload:
|
||||
PayloadSchema:
|
||||
OfType Array:
|
||||
InItems:
|
||||
OfType Object:
|
||||
InProperty "weight":
|
||||
- TypesRestricted [Number]
|
||||
- AdditionalToProperty
|
||||
- OfType Number: NoMatchingMultipleOf 1.0
|
||||
InParam "limit":
|
||||
InParamSchema:
|
||||
OfType Number: MatchingMaximumWeak (ProdCons {producer = Inclusive 30.0,
|
||||
consumer = Inclusive 20.0})
|
||||
InOperation PostMethod:
|
||||
InRequest:
|
||||
InPayload:
|
||||
PayloadSchema:
|
||||
OfType Object:
|
||||
InProperty "name":
|
||||
OfType String:
|
||||
- MatchingMaxLengthWeak (ProdCons {producer = 15, consumer = 10})
|
||||
- MatchingMinLengthWeak (ProdCons {producer = 1, consumer = 3})
|
@ -18,7 +18,7 @@ Tuple length changed from 3 to 2.
|
||||
|
||||
#### `$(Array)`
|
||||
|
||||
Tuple length changed from 2 to 3.
|
||||
Tuple length changed from 3 to 2.
|
||||
|
||||
# <span id="non-breaking-changes"></span>🙆 Non-breaking changes
|
||||
|
||||
@ -28,7 +28,7 @@ Tuple length changed from 2 to 3.
|
||||
|
||||
#### `$(Array)`
|
||||
|
||||
Tuple length changed from 2 to 3.
|
||||
Tuple length changed from 3 to 2.
|
||||
|
||||
### 📱⬅️ JSON Response – 200
|
||||
|
||||
|
@ -34,7 +34,7 @@ Minimum length of the array changed from 2 to 3.
|
||||
|
||||
#### `$(Array)`
|
||||
|
||||
1. Tuple length changed from 3 to 2.
|
||||
1. Tuple length changed from 2 to 3.
|
||||
|
||||
2. The array is no longer explicitly defined as a tuple.
|
||||
|
||||
@ -62,7 +62,7 @@ The array is no longer explicitly defined as a tuple.
|
||||
|
||||
#### `$(Array)`
|
||||
|
||||
1. Tuple length changed from 3 to 2.
|
||||
1. Tuple length changed from 2 to 3.
|
||||
|
||||
2. The array is no longer explicitly defined as a tuple.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user