OpenAPI Flashcards

1
Q

OpenApi specification generation (code first )

A

OpenUse Springdoc v2 for Spring framwork 6 (via reflection)

https://springdoc.org/

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.2.0</version>
</dependency>

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-common</artifactId>
<version>2.2.0</version>
</dependency>

In order to use this functionality, you need to add the plugin declaration on the plugins section of your pom.xml:

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-maven-plugin.version}</version>
<configuration>
<jvmArguments>-Dspring.application.admin.enabled=true</jvmArguments>
</configuration>
<executions>
<execution>
<goals>
<goal>start</goal>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Testing

A

Atlassian Swagger Request Validator - a rich library for testing HTTP requests and responses against an OpenApi specs
–> doesn not support SpringFramework6((delivered in Q1 2023??)) or WebFLux????
–> verifies specs in integration tests, Pact contracts or with RestAssured

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

For code generation

A
  • there is a maven plugin
  • usefull for consuming 3rd party APis with OpenAPI specs
  • can be used generate client side code(the quality depends on the quality of the specs)
  • generate server stubs
  • generate request/response POJO(usefull to generate in a common module that is shared across other projects)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly