Skip to content

Conversation

@frantuma
Copy link
Contributor

This PR addresses issues related to "reference items" instantiation, serialization and resolving, triggered originally by swagger-api/swagger-parser/issues/727 and swagger-api/swagger-parser/issues/713; it would replace #2847

It updates related code mainly:

  • providing an originalRef getter in "reference items" (e.g. RefModel, RefProperty, etc)
  • allowing to have this originalRef mapped to $ref JSON property via MixIn or added ReferenceSerializationConfigurer helper class
  • updating the ref parsing logic to identify as relative ref (and therefore not treating it as internal, which modifies the reference by adding the related prefix) non absolute nor explicitly internal properties containing a dot
  • allowing to maintain previous parsing behaviour by invoking at bootstrap GenericRef.internalRefWithAnyDot()

please see tests added in PR for some examples.

@frantuma frantuma merged commit d5f752e into 1.5 Aug 6, 2018
@gracekarina gracekarina deleted the ref-refactor branch August 10, 2018 22:02
Kortanul added a commit to Kortanul/wrensec-commons that referenced this pull request Nov 30, 2018
- `OpenApiTransformerTest.testBuildModel()` was revised to address two issues:
  - The way that exceptions were being tested was inadvertently squelching legitimate exceptions that might crop-up during the test, since it was catching `Exception` but only handling the exception if the data provider indicated an exception was expected. This has been re-written to use `assertThatExceptionOfType()` instead.
  - The way that models were being compared no longer worked after the update to Swagger 1.5.21. The "actual" and "expected" model instances can't be compared with `equals()` because Swagger changed the equality comparison rules in such a way that the models are no longer 100% equivalent. Instead, we have to compare the two models via their JSON representation.

    Specifically, Swagger now takes the `originalRef` field into account in the `equals()` method of `GenericRef`. For the "expected" model, the `originalRef` is `"urn:jsonschema:org:forgerock:api:transform:PojoInner"` but for the "actual" model, it is `"#/definitions/urn:jsonschema:org:forgerock:api:transform:PojoInner"`.

    For more details, see: swagger-api/swagger-core#2849

- Per notes in swagger-api/swagger-core#2944, JacksonUtils has been modified to use Swagger's own `Json.mapper()` factory method instead of constructing the `ObjectMapper` itself. Among other things, this ensures that `WRITE_DATES_AS_TIMESTAMPS` is off by default, and prevents the `originalRef` field from appearing in JSON schema output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants