Skip to content

Commit

Permalink
feat(blocktype): add documentation entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain Durand committed Jul 17, 2024
1 parent e5f8dd4 commit 3d84da8
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You simply need to generate the object and let your favorite JSON framework seri
<dependency>
<groupId>io.github.ouest-france</groupId>
<artifactId>bp-contract-generator</artifactId>
<version>1.0.0</version>
<version>1.0.2</version>
</dependency>
```

Expand All @@ -42,6 +42,9 @@ public class BlockProviderResource {
// the block type
.addType("bold").withVersion(1, 0, 0)

// set documentation
.withDocumentation("http://ww.google.fr")

// declare the endpoint url
.withEndpoint("https://localhost/block-configurations", "GET", "pure")

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.ouest-france</groupId>
<artifactId>bp-contract-generator</artifactId>
<version>1.0.1-SANPASHOT</version>
<version>1.0.2</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/sipa/blockprovider/BlockTypeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ public BlockTypeBuilder withVersion(final int major, final int minor, final int
return this;
}

/**
* Set the version of the block type.
*
* @param url external documentation url
* @return the block type builder
*/
public BlockTypeBuilder withDocumentation(final String url) {
this.blockConfiguration.setDocumentation(url);
return this;
}

/**
* Specify the endpoint settings associated with the block type.
*
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/sipa/blockprovider/domain/BlockConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
public class BlockConfiguration {

private String version;
private final Documentation documentation = new Documentation();
private final Endpoint endpoint = new Endpoint();
private final List<Template> templates = new ArrayList<>();

Expand All @@ -27,4 +28,14 @@ public void setVersion(final String version) {
public List<Template> getTemplates() {
return this.templates;
}

public Documentation getDocumentation() {
return this.documentation;
}

public void setDocumentation(final String url) { this.documentation.url = url; }

public class Documentation {
private String url;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ void shouldSerializeOneBlockType() {
// the block type
.addType("bold").withVersion(1, 0, 0)

// set documentation
.withDocumentation("http://ww.google.fr")

// declare the endpoint url
.withEndpoint("https://localhost/block-configurations", "GET", "pure")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ void shouldSerializeTwoBlockTypes() {
// the block type
.addType("bold").withVersion(1, 0, 0)

// set documentation
.withDocumentation("http://ww.google.fr")

// the input text
.addParameter("text")
.configurableAsString(null)
Expand Down

0 comments on commit 3d84da8

Please sign in to comment.