Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example values for request/response examples in swagger #1441

Merged
merged 26 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5e92446
Swagger support initial concept
strailov Aug 25, 2023
fe1197a
Add descriptions for Target tags
strailov Aug 25, 2023
013bd23
Add target filter queries descriptions
strailov Aug 25, 2023
2584b51
Add target api descriptions
strailov Aug 28, 2023
c9df0b2
Add software modules API descriptions
strailov Aug 28, 2023
64ed965
Add descriptions for DS, DSTags and SMTypes
strailov Aug 29, 2023
041c572
Add DistributionSetType API descriptions
strailov Aug 29, 2023
b58bef5
Add Rollout API descriptions
strailov Aug 29, 2023
15d2de3
Bring back test scope to mariaDb
strailov Aug 29, 2023
e74a0f2
Add tags and descriptions to System config API
strailov Sep 4, 2023
822cabc
Move away OpenAPI config from Start.java
strailov Sep 4, 2023
2f5e3fa
provide license header and project version for openapi
strailov Sep 4, 2023
4e51224
Fix error responses with example error body
strailov Sep 7, 2023
99e4eb8
Add DDI API to swagger and make proper API grouping
strailov Sep 25, 2023
61d7391
Merge from master
strailov Sep 25, 2023
02493a2
Revert changes from not merging before commit
strailov Sep 25, 2023
0379256
Remove more changes
strailov Sep 25, 2023
47c393b
fix circle ci build
strailov Sep 25, 2023
04b4ed1
Merge branch 'master' into feature/swagger_support
strailov Sep 25, 2023
bf2cdc5
Add missing descriptions for downloadArtifact methods in DDI
strailov Sep 25, 2023
99d6bda
Make configuration for openApi conditional for flexibility in transit…
strailov Sep 26, 2023
590e03f
Make beans conditional not config
strailov Sep 26, 2023
fec02b7
Remove oAuth and switch to more general description
strailov Sep 27, 2023
b13178c
remove comment
strailov Sep 27, 2023
c1217ff
Merge branch 'master' into feature/swagger_support
strailov Sep 29, 2023
1d12e51
Add example schema values for request responses examples
strailov Sep 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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