Skip to content

Commit

Permalink
Third try to fix conflicts and... build!
Browse files Browse the repository at this point in the history
  • Loading branch information
elraro committed Oct 13, 2022
1 parent 483f98a commit 7481eba
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 153 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const StateAttribute = require("./StateAttribute");

class OperationModeStateAttribute extends StateAttribute {
/**
* @param {object} options
* @param {OperationModeAttributeValue} options.value
* @param {object} [options.metaData]
*/
constructor(options) {
super(options);

this.value = options.value;
}

/**
*
* @param {OperationModeStateAttribute} otherAttribute
* @return {boolean}
*/
equals(otherAttribute) {
return this.__class === otherAttribute.__class &&
this.type === otherAttribute.type &&
this.subType === otherAttribute.subType &&
this.value === otherAttribute.value;
}
}

/**
* @typedef {string} OperationModeAttributeValue
* @enum {string}
*
*/
OperationModeStateAttribute.VALUE = Object.freeze({
VACUUM: "vacuum",
MOP: "mop",
VACUUM_AND_MOP: "vacuum_and_mop"
});


module.exports = OperationModeStateAttribute;
1 change: 1 addition & 0 deletions backend/lib/entities/state/attributes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
BatteryStateAttribute: require("./BatteryStateAttribute"),
ConsumableStateAttribute: require("./ConsumableStateAttribute"),
DockStatusStateAttribute: require("./DockStatusStateAttribute"),
OperationModeStateAttribute: require("./OperationModeStateAttribute"),
PresetSelectionStateAttribute: require("./PresetSelectionStateAttribute"),
StatusStateAttribute: require("./StatusStateAttribute")
};
176 changes: 23 additions & 153 deletions util/build_openapi_schema.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import * as path from "path";
const __dirname = path.resolve();

process.on("uncaughtException", function (err) {
// eslint-disable-next-line no-console
console.log(err);
process.exit(1);
// eslint-disable-next-line no-console
console.log(err);
process.exit(1);
});

const options = {
Expand Down Expand Up @@ -80,161 +80,31 @@ const options = {
{BasicAuth: []}
],
},
servers: [{ url: "../" }],
tags: [
//Swagger UI respects the order of these
{ name: "Valetudo", description: "Valetudo management API" },
{ name: "ValetudoEvents", description: "Valetudo Events" },
{ name: "Robot", description: "Robot API" },
{ name: "System", description: "System API" },
{ name: "NTP", description: "NTP Client API" },
{ name: "Timers", description: "Timers API" },
{ name: "Updater", description: "Update Valetudo using Valetudo" },

{
name: "BasicControlCapability",
description: "Basic control capability",
},
{
name: "FanSpeedControlCapability",
description: "Fan speed control capability",
},
{
name: "WaterUsageControlCapability",
description: "Water usage control capability",
},
{
name: "WifiConfigurationCapability",
description: "Wi-Fi configuration capability",
},
{ name: "WifiScanCapability", description: "Wi-Fi scan capability" },
{
name: "ZoneCleaningCapability",
description: "Zone cleaning capability",
},
{
name: "MapSegmentationCapability",
description: "Map segment cleaning capability",
},
{
name: "ManualControlCapability",
description: "Manual control capability",
},
{
name: "DoNotDisturbCapability",
description: "Do-not-disturb configuration capability",
},
{
name: "ConsumableMonitoringCapability",
description: "Consumable monitoring capability",
},
{ name: "LocateCapability", description: "Robot locate capability" },
{
name: "GoToLocationCapability",
description: "Go-to location capability",
},
{
name: "CarpetModeControlCapability",
description: "Carpet mode settings capability",
},
{ name: "MapResetCapability", description: "Map reset capability" },
{
name: "MapSegmentEditCapability",
description: "Map segment edit capability",
},
{
name: "MapSegmentRenameCapability",
description: "Map segment rename capability",
},
{
name: "MapSnapshotCapability",
description: "Map snapshots capability",
},
{
name: "PersistentMapControlCapability",
description: "Persistent map control capability",
},
{
name: "SensorCalibrationCapability",
description: "Sensor calibration capability",
},
{ name: "SpeakerTestCapability", description: "Speaker test capability" },
{
name: "SpeakerVolumeControlCapability",
description: "Speaker volume control capability",
},
{
name: "VoicePackManagementCapability",
description: "Voice pack management capability",
},
{
name: "CombinedVirtualRestrictionsCapability",
description: "Combined virtual restrictions capability",
},
{
name: "PendingMapChangeHandlingCapability",
description: "Pending map change handling capability",
},
{ name: "MappingPassCapability", description: "Mapping pass capability" },
{ name: "KeyLockCapability", description: "Key lock capability" },
],
components: {
responses: {
200: { description: "Ok" },
201: { description: "Created" },
202: { description: "Accepted" },
400: { description: "Bad request" },
403: { description: "Forbidden" },
404: { description: "Not found" },
500: { description: "Internal server error" },
},
parameters: {},
securitySchemes: {
BasicAuth: {
type: "http",
scheme: "basic",
},
},
},
security: [{ BasicAuth: [] }],
},
apis: [
path.join(__dirname, "./backend/util/openapi_defs/*.openapi.json"),
path.join(__dirname, "./backend/lib/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/webserver/doc/*.openapi.json"),
path.join(
__dirname,
"./backend/lib/webserver/capabilityRouters/doc/*.openapi.json"
),
path.join(
__dirname,
"./backend/lib/webserver/middlewares/doc/*.openapi.json"
),
path.join(__dirname, "./backend/lib/entities/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/entities/map/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/entities/core/doc/*.openapi.json"),
path.join(
__dirname,
"./backend/lib/entities/core/ntpClient/doc/*.openapi.json"
),
path.join(
__dirname,
"./backend/lib/entities/core/updater/doc/*.openapi.json"
),
path.join(__dirname, "./backend/lib/entities/state/doc/*.openapi.json"),
path.join(
__dirname,
"./backend/lib/entities/state/attributes/doc/*.openapi.json"
),
path.join(__dirname, "./backend/lib/core/capabilities/doc/*.openapi.json"),
],
apis: [
path.join(__dirname, "./backend/util/openapi_defs/*.openapi.json"),
path.join(__dirname, "./backend/lib/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/webserver/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/webserver/capabilityRouters/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/webserver/middlewares/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/entities/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/entities/map/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/entities/core/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/entities/core/ntpClient/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/entities/core/updater/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/entities/state/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/entities/state/attributes/doc/*.openapi.json"),
path.join(__dirname, "./backend/lib/core/capabilities/doc/*.openapi.json")
]
};

const spec = await swaggerJsdoc(options);

await SwaggerParser.validate(spec);


fs.writeFileSync(
path.join(__dirname, "./backend/lib/res/valetudo.openapi.schema.json"),
JSON.stringify(spec)
path.join(__dirname, "./backend/lib/res/valetudo.openapi.schema.json"),
JSON.stringify(spec)
);


0 comments on commit 7481eba

Please sign in to comment.