wiremock / spec

WireMock Specifications
Apache License 2.0
2 stars 0 forks source link

Identify and collect gaps in the Admin API JSON schemas #3

Open picimako opened 1 year ago

picimako commented 1 year ago

JSON schema gaps

As per https://github.com/wiremock/wiremock/issues/2258 and https://github.com/wiremock/wiremock/pull/2253 this issue attempts to collect missing JSON schema properties for the WireMock Java Admin API, and a few improvement candidates/questions, and where possible, with proposed solutions at the end of this issue.

Collection of schema properties

Schema Property Java class Comment
request-pattern urlPathTemplate RequestPattern The description of the other url* properties must also mention this property.
request-pattern formParameters RequestPattern
request-pattern pathParameters RequestPattern
request-pattern customMatcher CustomMatcherDefinition This is not a missing property. Instead, if its name property is mandatory, it could be marked as such.
response-definition jsonBody ResponseDefinition This is not a missing property. Since the Java side accepts a com.fasterxml.jackson.databind.JsonNode,
it is a question if the property type can also be an array, and any other type besides object.
response-definition chunkedDribbleDelay ChunkedDribbleDelay
response-definition proxyUrlPrefixToRemove ResponseDefinition
delay-distribution fixed ResponseDefinition
DelayDistribution
FixedDelayDistribution
scenario mappings Scenario
scenario possibleStates Scenario This is not a missing property. Instead, it is ignored on Java side. The Java code could be extended with a comment about the reason why it is ignored.
logged-request clientIp LoggedRequest
logged-request browserProxyRequest LoggedRequest
logged-request loggedDate LoggedRequest
logged-request bodyAsBase64 LoggedRequest
logged-request multiparts LoggedRequest
logged-request protocol LoggedRequest
record-spec targetBaseUrl RecordSpec
record-spec filters RecordSpec
record-spec outputFormat RecordSpec
SnapshotOutputFormatter
content-pattern XML equality section:
enablePlaceholders
placeholderOpeningDelimiterRegex
placeholderClosingDelimiterRegex
exemptedComparisons
EqualToXmlPattern
StringValuePatternJsonDeserializer
content-pattern JSONPath match section MatchesJsonPathPattern
StringValuePatternJsonDeserializer
Based on MatchesJsonPathPattern and StringValuePatternJsonDeserializer JSONPath matching doesn't seem to use the ignoreArrayOrder and ignoreExtraElements properties.
content-pattern XPath match section:
xPathNamespaces
MatchesXPathPattern
StringValuePatternJsonDeserializer
content-pattern JSON equals section:
ignoreArrayOrder
ignoreExtraElements
EqualToJsonPattern
StringValuePatternJsonDeserializer
content-pattern String equals section EqualToPattern
StringValuePatternJsonDeserializer
The type of the equalTo property should be string instead of boolean.

Additionally in content-pattern, sections are missing for the following classes: MatchesJsonSchemaPattern, NotPattern, NegativeContainsPattern, BeforeDateTimePattern, AfterDateTimePattern, EqualToDateTimePattern, AnythingPattern?, AbsentPattern, LogicalAnd, LogicalOr, PathTemplatePattern.

Proposals for schema improvement

request-pattern / urlPathTemplate

  urlPathTemplate:
    type: string
    description: The path template to match against. Only one of url, urlPattern, urlPath, urlPathPattern or urlPathTemplate may be specified.

request-pattern / formParameters

  formParameters:
    type: object
    description: 'Form parameter patterns to match against in the <key>: { "<predicate>": "<value>" } form'

request-pattern / pathParameters

  pathParameters:
    type: object
    description: 'Path variables with matchers for the parameters specified in urlPathTemplate.'

response-definition / chunkedDribbleDelay

  chunkedDribbleDelay:
    type: object
    description: ...
    properties:
      numberOfChunks:
        type: integer
      totalDuration:
        type: integer

response-definition / proxyUrlPrefixToRemove

  proxyUrlPrefixToRemove:
    type: string
    description: ...

delay-distribution / fixed

  - title: Fixed
    description: Fixed distribution of response delay.
    type: object
    properties:
      millisecond:
        type: integer

scenario / mappings

  mappings:
    $ref: 'stub-mapping.yaml'

record-spec / targetBaseUrl

  targetBaseUrl:
    type: string
    description: ...

record-spec / outputFormat

  outputFormat:
    type: string
    description: ...
    default: FULL
    enum:
      - FULL
      - IDS