mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.57k stars 1.07k forks source link

MockServer fails to process/use OpenApi-Spec because $ref is not resolved correctly. #1020

Closed hummelfe94 closed 2 years ago

hummelfe94 commented 3 years ago

Describe the issue MockServer fails to load OpenAPI spec because it can't resolve $ref to array type in openApi-Spec.

What you are trying to do Create mockserver and do some verification as describe in https://mock-server.com/mock_server/verification.html ("verify requests received at exactly once by openapi and operation")

MockServer version testImplementation group: 'org.mock-server', name: 'mockserver-junit-jupiter', version: '5.11.2' testImplementation group: 'com.github.java-json-tools', name: 'json-schema-validator', version: '2.0.4'

To Reproduce Steps to reproduce the issue:

  1. Create JUNIT-Test with @ExtendWith({ MockServerExtension.class}), MockServerSettings(ports = 1080)
  2. Create MockServerClient with OpenAPI File content provided below
  3. java.lang.IllegalArgumentException: Unable to load API spec, Unable to load RELATIVE ref: emsp2.2cdrs_cdr_token

Expected behaviour The openApi file is loaded without any errors.

MockServer Log image

Problem is that the array reference is not resolved correctly: image

Excerpt of my openApi-File is below in the .zip file

hummelfe94 commented 3 years ago

openapi-spec-ocpi-v2.2.zip

TheCycoONE commented 2 years ago

This also happens with Twilio's OpenAPI spec: https://raw.githubusercontent.com/twilio/twilio-oai/main/spec/json/twilio_api_v2010.json

Unable to load API spec, Unable to load RELATIVE ref: api.v2010.account.available_phone_number_country.available_phone_number_local_capabilities*

jamesdbloom commented 2 years ago

This has now been fixed in the SNAPSHOT version which will be released in the next couple of weeks so closing here.