Skip to content

Commit

Permalink
Add example values for request/response examples in swagger (#1441)
Browse files Browse the repository at this point in the history
* Swagger support initial concept

Signed-off-by: Stanislav Trailov <[email protected]>

* Add descriptions for Target tags

Signed-off-by: Stanislav Trailov <[email protected]>

* Add target filter queries descriptions

Signed-off-by: Stanislav Trailov <[email protected]>

* Add target api descriptions

Signed-off-by: Stanislav Trailov <[email protected]>

* Add software modules API descriptions

Signed-off-by: Stanislav Trailov <[email protected]>

* Add descriptions for DS, DSTags and SMTypes

Signed-off-by: Stanislav Trailov <[email protected]>

* Add DistributionSetType API descriptions

Signed-off-by: Stanislav Trailov <[email protected]>

* Add Rollout API descriptions

Signed-off-by: Stanislav Trailov <[email protected]>

* Bring back test scope to mariaDb

Signed-off-by: Stanislav Trailov <[email protected]>

* Add tags and descriptions to System config API

Signed-off-by: Stanislav Trailov <[email protected]>

* Move away OpenAPI config from Start.java

Signed-off-by: Stanislav Trailov <[email protected]>

* provide license header and project version for openapi

Signed-off-by: Stanislav Trailov <[email protected]>

* Fix error responses with example error body

Signed-off-by: Stanislav Trailov <[email protected]>

* Add DDI API to swagger and make proper API grouping

Signed-off-by: Stanislav Trailov <[email protected]>

* Revert changes from not merging before commit

Signed-off-by: Stanislav Trailov <[email protected]>

* Remove more changes

Signed-off-by: Stanislav Trailov <[email protected]>

* fix circle ci build

Signed-off-by: Stanislav Trailov <[email protected]>

* Add missing descriptions for downloadArtifact methods in DDI

Signed-off-by: Stanislav Trailov <[email protected]>

* Make configuration for openApi conditional for flexibility in transitive dependencies

Signed-off-by: Stanislav Trailov <[email protected]>

* Make beans conditional not config

Signed-off-by: Stanislav Trailov <[email protected]>

* Remove oAuth and switch to more general description

Signed-off-by: Stanislav Trailov <[email protected]>

* remove comment

Signed-off-by: Stanislav Trailov <[email protected]>

* Add example schema values for request responses examples

Signed-off-by: Stanislav Trailov <[email protected]>

---------

Signed-off-by: Stanislav Trailov <[email protected]>
  • Loading branch information
strailov authored Sep 29, 2023
1 parent 5eb84cb commit 60f1469
Show file tree
Hide file tree
Showing 68 changed files with 279 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

/**
* <p>
Expand All @@ -39,6 +40,7 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class DdiActionFeedback {

@Schema(example = "2023-08-03T12:31:41.890992967Z")
private final String time;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.util.List;

import io.swagger.v3.oas.annotations.media.Schema;
import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi;

import com.fasterxml.jackson.annotation.JsonCreator;
Expand All @@ -32,6 +33,7 @@
public class DdiActionHistory {

@JsonProperty("status")
@Schema(example = "RUNNING")
private final String actionStatus;

@JsonProperty("messages")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

@JsonIgnoreProperties(ignoreUnknown = true)
public class DdiActivateAutoConfirmation {

@JsonProperty(required = false)
@Schema(example = "exampleUser")
private final String initiator;

@JsonProperty(required = false)
@Schema(example = "exampleRemark")
private final String remark;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import javax.validation.constraints.NotNull;

import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.hateoas.RepresentationModel;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
Expand All @@ -25,12 +26,14 @@ public class DdiArtifact extends RepresentationModel<DdiArtifact> {

@NotNull
@JsonProperty
@Schema(example = "binary.tgz")
private String filename;

@JsonProperty
private DdiArtifactHash hashes;

@JsonProperty
@Schema(example = "3")
private Long size;

public DdiArtifactHash getHashes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

/**
* Hashes for given Artifact.
Expand All @@ -21,13 +22,16 @@
public class DdiArtifactHash {

@JsonProperty
@Schema(example = "2d86c2a659e364e9abba49ea6ffcd53dd5559f05")
private String sha1;

@JsonProperty
@Schema(example = "0d1b08c34858921bc7c662b228acb7ba")
private String md5;

@JsonProperty
@JsonInclude(Include.NON_NULL)
@Schema(example = "a03b221c6c6eae7122ca51695d456d5222e524889136394944b2f9763b483615")
private String sha256;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.hateoas.RepresentationModel;

@JsonInclude(JsonInclude.Include.NON_NULL)
Expand All @@ -22,10 +23,14 @@
public class DdiAutoConfirmationState extends RepresentationModel<DdiAutoConfirmationState> {

@NotNull
@Schema(example = "true")
private boolean active;
@Schema(example = "exampleUserId")
private String initiator;
@Schema(example = "exampleRemark")
private String remark;

@Schema(example = "1691065895439")
private Long activatedAt;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

/**
* Cancel action to be provided to the target.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class DdiCancel {

@Schema(example = "11")
private final String id;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

/**
* The action that has to be stopped by the target.
Expand All @@ -22,6 +23,7 @@
public class DdiCancelActionToStop {

@NotNull
@Schema(example = "11")
private final String stopId;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

/**
* Deployment chunks.
Expand All @@ -26,14 +27,17 @@ public class DdiChunk {

@JsonProperty("part")
@NotNull
@Schema(example = "bApp")
private String part;

@JsonProperty("version")
@NotNull
@Schema(example = "1.2.0")
private String version;

@JsonProperty("name")
@NotNull
@Schema(example = "oneApp")
private String name;

@JsonProperty("encrypted")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.hawkbit.ddi.json.model;
package org.eclipse.hawkbit.ddi.json.model;

import java.util.HashMap;
import java.util.Map;

import javax.validation.constraints.NotEmpty;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

/**
* Feedback channel for ConfigData action.
Expand All @@ -26,6 +28,7 @@ public class DdiConfigData {
@NotEmpty
private final Map<String, String> data;

@Schema(example = "merge")
private final DdiUpdateMode mode;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.hateoas.RepresentationModel;

import javax.validation.constraints.NotNull;
Expand All @@ -27,6 +28,7 @@ public class DdiConfirmationBaseAction extends RepresentationModel<DdiConfirmati

@JsonProperty("id")
@NotNull
@Schema(example = "6")
private String id;

@JsonProperty("confirmation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
Expand All @@ -32,6 +33,7 @@ public class DdiConfirmationFeedback {
@Valid
private final Confirmation confirmation;

@Schema(example = "200")
private final Integer code;

private final List<String> details;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import javax.validation.constraints.NotNull;

import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.hateoas.RepresentationModel;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
Expand All @@ -27,6 +28,7 @@ public class DdiDeploymentBase extends RepresentationModel<DdiDeploymentBase> {

@JsonProperty("id")
@NotNull
@Schema(example = "8")
private String id;

@JsonProperty("deployment")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

/**
* Additional metadata to be provided for the target/device.
Expand All @@ -23,10 +24,12 @@
public class DdiMetadata {
@JsonProperty
@NotNull
@Schema(example = "aMetadataKey")
private final String key;

@JsonProperty
@NotNull
@Schema(example = "Metadata value as defined in software module")
private final String value;

@JsonCreator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;

/**
* Polling interval for the SP target.
Expand All @@ -22,6 +26,7 @@
public class DdiPolling {

@JsonProperty
@Schema(example = "12:00:00")
private String sleep;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

/**
* Action fulfillment progress by means of gives the achieved amount of maximal
Expand All @@ -23,8 +24,10 @@
public class DdiProgress {

@NotNull
@Schema(example = "2")
private final Integer cnt;

@Schema(example = "5")
private final Integer of;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.v3.oas.annotations.media.Schema;

/**
* Result information of the action progress which can by an intermediate or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.v3.oas.annotations.media.Schema;

/**
* Details status information concerning the action processing.
Expand All @@ -34,6 +35,7 @@ public class DdiStatus {
@Valid
private final DdiResult result;

@Schema(example = "200")
private final Integer code;

private final List<String> details;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,9 @@ ResponseEntity<DdiDeploymentBase> getControllerInstalledAction(@PathVariable("te
""")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = """
""", content = @Content(schema = @Schema(oneOf = {}))), //TODO: 2 RESPONSES WHEN AUTO CONFIRMATION IS ACTIVE OR NOT
The response body in case auto-confirmation is active is richer - it contains additional information
such as initiator, remark and when the auto-confirmation had been activated.
"""),
@ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionInfo.class))),
@ApiResponse(responseCode = "401", description = "The request requires user authentication.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Insufficient permissions, entity is not allowed to be changed (i.e. read-only) or data volume restriction applies.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.mgmt.json.model;

import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.RepresentationModel;

Expand All @@ -22,15 +23,19 @@
public abstract class MgmtBaseEntity extends RepresentationModel<MgmtBaseEntity> {

@JsonProperty
@Schema(example = "bumlux")
private String createdBy;

@JsonProperty
@Schema(example = "1691065905897")
private Long createdAt;

@JsonProperty
@Schema(example = "bumlux")
private String lastModifiedBy;

@JsonProperty
@Schema(example = "1691065906407")
private Long lastModifiedAt;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.v3.oas.annotations.media.Schema;

/**
* A generic abstract rest model which contains only a ID for use-case e.g.
Expand All @@ -20,6 +21,7 @@
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class MgmtId {
@Schema(example = "108")
private Long id;

/**
Expand Down
Loading

0 comments on commit 60f1469

Please sign in to comment.