-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(deps): update restdocs-api-spec to v0.19.0
Adds support for `contact` object in the mojo parameters.
- Loading branch information
Showing
16 changed files
with
355 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...ocs-spec-generator/src/main/java/com/berkleytechnologyservices/restdocs/spec/Contact.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.berkleytechnologyservices.restdocs.spec; | ||
|
||
public class Contact { | ||
|
||
private String name; | ||
private String email; | ||
private String url; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package com.berkleytechnologyservices.restdocs.spec.generator.openapi_v3; | ||
|
||
import com.berkleytechnologyservices.restdocs.spec.ApiDetails; | ||
import com.berkleytechnologyservices.restdocs.spec.Contact; | ||
import com.berkleytechnologyservices.restdocs.spec.Specification; | ||
import com.berkleytechnologyservices.restdocs.spec.generator.SpecificationGeneratorException; | ||
import com.epages.restdocs.apispec.model.HTTPMethod; | ||
|
@@ -49,6 +50,21 @@ public void testGenerateHostWithPort() throws SpecificationGeneratorException { | |
.isEqualToNormalizingNewlines(contentOfResource("/mock-specs/openapi3/host-with-port.yml")); | ||
} | ||
|
||
@Test | ||
public void testGenerateContact() throws SpecificationGeneratorException { | ||
Contact contact = new Contact(); | ||
contact.setName("John Doe"); | ||
contact.setEmail("[email protected]"); | ||
contact.setUrl("https://john.example.com"); | ||
|
||
ApiDetails apiDetails = new ApiDetails().contact(contact); | ||
|
||
String rawOutput = generator.generate(apiDetails, list(getMockResource())); | ||
|
||
assertThat(rawOutput) | ||
.isEqualToNormalizingNewlines(contentOfResource("/mock-specs/openapi3/contact.yml")); | ||
} | ||
|
||
private ResourceModel getMockResource() { | ||
return resource( | ||
"book-get", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
restdocs-spec-generator/src/test/resources/mock-specs/openapi3/contact.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: API Documentation | ||
contact: | ||
name: John Doe | ||
url: https://john.example.com | ||
email: [email protected] | ||
version: 1.0.0 | ||
servers: | ||
- url: http://localhost | ||
tags: [] | ||
paths: | ||
/book/{id}: | ||
get: | ||
tags: | ||
- book | ||
summary: Get a book by id | ||
description: Get a book by id | ||
operationId: book-get | ||
parameters: | ||
- name: id | ||
in: path | ||
description: The unique identifier for the book. | ||
required: true | ||
schema: | ||
type: number | ||
responses: | ||
"200": | ||
description: "200" | ||
content: | ||
application/hal+json: | ||
schema: | ||
$ref: '#/components/schemas/MyCustomSchemaName' | ||
examples: | ||
book-get: | ||
value: The example response. | ||
components: | ||
schemas: | ||
MyCustomSchemaName: | ||
title: MyCustomSchemaName | ||
required: | ||
- author | ||
- pages | ||
- title | ||
type: object | ||
properties: | ||
pages: | ||
type: number | ||
description: Number of pages in the book | ||
author: | ||
type: string | ||
description: Author of the book | ||
title: | ||
type: string | ||
description: Title of the book |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.github.berkleytechnologyservices.restdocs-spec.it</groupId> | ||
<artifactId>default-settings-it</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<description>Verify the default settings.</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>3.3.1</version> | ||
<executions> | ||
<execution> | ||
<id>copy-resources</id> | ||
<phase>validate</phase> | ||
<goals> | ||
<goal>copy-resources</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${project.basedir}/target/generated-snippets</outputDirectory> | ||
<resources> | ||
<resource> | ||
<directory>snippets</directory> | ||
<filtering>false</filtering> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<version>@project.version@</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>generate</goal> | ||
</goals> | ||
<configuration> | ||
<specification>OPENAPI_V3</specification> | ||
<contact> | ||
<name>John Doe</name> | ||
<email>[email protected]</email> | ||
<url>https://john.example.com</url> | ||
</contact> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
26 changes: 26 additions & 0 deletions
26
restdocs-spec-maven-plugin/src/it/openapi-3.0/snippets/cart-add-product/resource.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"operationId" : "cart-add-product", | ||
"summary" : "Add products to a cart", | ||
"description" : "Add products to a cart", | ||
"privateResource" : false, | ||
"deprecated" : false, | ||
"request" : { | ||
"path" : "/carts/{id}/products", | ||
"method" : "POST", | ||
"contentType" : "text/uri-list", | ||
"headers" : [ ], | ||
"pathParameters" : [ ], | ||
"queryParameters" : [ ], | ||
"formParameters" : [ ], | ||
"requestFields" : [ ], | ||
"example" : "http://localhost/products/1", | ||
"securityRequirements" : null | ||
}, | ||
"response" : { | ||
"status" : 200, | ||
"contentType" : "application/hal+json", | ||
"headers" : [ ], | ||
"responseFields" : [ ], | ||
"example" : "{\r\n \"total\" : 49.99,\r\n \"products\" : [ {\r\n \"quantity\" : 1,\r\n \"product\" : {\r\n \"name\" : \"Fancy pants\",\r\n \"price\" : 49.99\r\n },\r\n \"_links\" : {\r\n \"product\" : {\r\n \"href\" : \"http://localhost:8080/products/1\"\r\n }\r\n }\r\n } ],\r\n \"_links\" : {\r\n \"self\" : {\r\n \"href\" : \"http://localhost:8080/carts/1\"\r\n },\r\n \"order\" : {\r\n \"href\" : \"http://localhost:8080/carts/1/order\"\r\n }\r\n }\r\n}" | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
restdocs-spec-maven-plugin/src/it/openapi-3.0/snippets/cart-get/resource.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{ | ||
"operationId" : "cart-get", | ||
"summary" : "Get a cart by id", | ||
"description" : "Get a cart by id", | ||
"privateResource" : false, | ||
"deprecated" : false, | ||
"request" : { | ||
"path" : "/carts/{id}", | ||
"method" : "GET", | ||
"contentType" : null, | ||
"headers" : [ ], | ||
"pathParameters" : [ { | ||
"name" : "id", | ||
"description" : "the cart id", | ||
"ignored" : false, | ||
"type" : "STRING", | ||
"optional" : false | ||
} ], | ||
"queryParameters" : [ ], | ||
"formParameters" : [ ], | ||
"requestFields" : [ ], | ||
"example" : null, | ||
"securityRequirements" : null | ||
}, | ||
"response" : { | ||
"status" : 200, | ||
"contentType" : "application/hal+json", | ||
"headers" : [ ], | ||
"responseFields" : [ { | ||
"description" : "Total amount of the cart.", | ||
"ignored" : false, | ||
"path" : "total", | ||
"type" : "NUMBER", | ||
"optional" : false | ||
}, { | ||
"description" : "The product line item of the cart.", | ||
"ignored" : false, | ||
"path" : "products", | ||
"type" : "ARRAY", | ||
"optional" : false | ||
}, { | ||
"description" : "Link to the product.", | ||
"ignored" : false, | ||
"path" : "products[]._links.product", | ||
"type" : "OBJECT", | ||
"optional" : false | ||
}, { | ||
"description" : "The quantity of the line item.", | ||
"ignored" : false, | ||
"path" : "products[].quantity", | ||
"type" : "NUMBER", | ||
"optional" : false | ||
}, { | ||
"description" : "The product the line item relates to.", | ||
"ignored" : false, | ||
"path" : "products[].product", | ||
"type" : "OBJECT", | ||
"optional" : false | ||
}, { | ||
"description" : "Links section.", | ||
"ignored" : false, | ||
"path" : "_links", | ||
"type" : "OBJECT", | ||
"optional" : false | ||
} ], | ||
"example" : "{\r\n \"total\" : 49.99,\r\n \"products\" : [ {\r\n \"quantity\" : 1,\r\n \"product\" : {\r\n \"name\" : \"Fancy pants\",\r\n \"price\" : 49.99\r\n },\r\n \"_links\" : {\r\n \"product\" : {\r\n \"href\" : \"http://localhost:8080/products/2\"\r\n }\r\n }\r\n } ],\r\n \"_links\" : {\r\n \"self\" : {\r\n \"href\" : \"http://localhost:8080/carts/2\"\r\n },\r\n \"order\" : {\r\n \"href\" : \"http://localhost:8080/carts/2/order\"\r\n }\r\n }\r\n}" | ||
} | ||
} |
Oops, something went wrong.