assertj-swagger | Swagger assertj test library | REST library
kandi X-RAY | assertj-swagger Summary
kandi X-RAY | assertj-swagger Summary
assertj-swagger is a assertj library which compares a contract-first Swagger YAML/JSON file with a code-first Swagger JSON output (e.g. from springfox or JAX-RS Swagger). assertj-swagger allows to validate that the API implementation is in compliance with a contract specification for two test patterns: Documentation Driven Contracts and Consumer Driven Contracts. The Documentation Driven Contracts test pattern, useful for public APIs, validates using #isEqualTo and will validate that the design first documentation contract matches the implementation in its entirety. The Consumer Driven Contracts test pattern, useful for internal microservice APIs, validates using #satisfiesContract and will validate that the implementation provides, at minimum, the requirements of the design first consumer contract. This pattern allows for extension points in the API resources, resource methods, and models. The library supports the Swagger v2.0 specification. assertj-swagger compares Swagger objects like Paths, Parameters and Definitions. It does not compare unimportant Swagger objects like info, descriptions or summaries.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of assertj-swagger
assertj-swagger Key Features
assertj-swagger Examples and Code Snippets
Community Discussions
Trending Discussions on assertj-swagger
QUESTION
I'm trying to adopt Swagger in REST API development (Spring Boot web application). API documenting process and code generation based on swagger spec works good, and now I've faced a problem writing integration tests using assertj-swagger and SpringFox libraries.
A few little words about these libraries. Springfox works by examining an application, once, at runtime to infer API semantics based on Spring configurations, class structure and various compile time java annotations. The swagger-assertj test library should compare a contract-first Swagger YAML file with a code-first Swagger JSON generated by SpringFox. For Consumer Driven Contract tests, assertj-swagger fails a test if it finds missing resources, methods, models, or properties in the implementation which are required by the consumer specification.
My test looks like (test code is taken from GitHub example):
...ANSWER
Answered 2017-Jul-06 at 10:45I've managed to run my AssertJSwaggerConsumerDrivenTest
! I think I've never been so happy to see a lot of red test results before =) Anyway it's better than running test forever.
AssertJ-Swagger's readme is a little bit outdated. Here's what I changed to fix the problem.
Test code:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install assertj-swagger
You can use assertj-swagger like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the assertj-swagger component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page