Skip to content

Commit

Permalink
prepare for v3
Browse files Browse the repository at this point in the history
  • Loading branch information
kashike committed Apr 28, 2024
1 parent b57ea18 commit 8b1d897
Show file tree
Hide file tree
Showing 27 changed files with 841 additions and 365 deletions.
37 changes: 37 additions & 0 deletions src/main/java/io/papermc/bibliothek/api/model/Change.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* This file is part of bibliothek, licensed under the MIT License.
*
* Copyright (c) 2019-2024 PaperMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.api.model;

import io.swagger.v3.oas.annotations.media.Schema;

@Schema
public record Change(
@Schema(name = "commit")
String commit,
@Schema(name = "summary")
String summary,
@Schema(name = "message")
String message
) {
}
33 changes: 33 additions & 0 deletions src/main/java/io/papermc/bibliothek/api/model/Channel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* This file is part of bibliothek, licensed under the MIT License.
*
* Copyright (c) 2019-2024 PaperMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.api.model;

import com.fasterxml.jackson.annotation.JsonProperty;

public enum Channel {
@JsonProperty("default")
DEFAULT,
@JsonProperty("experimental")
EXPERIMENTAL;
}
39 changes: 39 additions & 0 deletions src/main/java/io/papermc/bibliothek/api/model/Download.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This file is part of bibliothek, licensed under the MIT License.
*
* Copyright (c) 2019-2024 PaperMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.api.model;

import io.swagger.v3.oas.annotations.media.Schema;
import org.intellij.lang.annotations.Language;

@Schema
public record Download(
@Schema(name = "name", pattern = "[a-z0-9._-]+", example = "paper-1.18-10.jar")
String name,
@Schema(name = "sha256", pattern = "[a-f0-9]{64}", example = "f065e2d345d9d772d5cf2a1ce5c495c4cc56eb2fcd6820e82856485fa19414c8")
String sha256
) {
// NOTE: this pattern cannot contain any capturing groups
@Language("RegExp")
public static final String NAME_PATTERN = "[a-zA-Z0-9._-]+";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* This file is part of bibliothek, licensed under the MIT License.
*
* Copyright (c) 2019-2024 PaperMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.api.response.v2;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.papermc.bibliothek.api.model.Change;
import io.papermc.bibliothek.api.model.Channel;
import io.papermc.bibliothek.api.model.Download;
import io.papermc.bibliothek.api.serialization.LegacyChannelSerializer;
import io.papermc.bibliothek.database.model.VersionEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.Instant;
import java.util.List;
import java.util.Map;

@Schema
public record BuildResponse(
@Schema(name = "project_id", pattern = "[a-z]+", example = "paper")
String project_id,

@Schema(name = "project_name", example = "Paper")
String project_name,

@Schema(name = "version", pattern = VersionEntity.PATTERN, example = "1.18")
String version,

@Schema(name = "build", pattern = "\\d+", example = "10")
int build,

@Schema(name = "time")
Instant time,

@JsonSerialize(using = LegacyChannelSerializer.class)
@Schema(name = "channel")
Channel channel,

@Schema(name = "promoted")
boolean promoted,

@Schema(name = "changes")
List<Change> changes,

@Schema(name = "downloads")
Map<String, Download> downloads
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* This file is part of bibliothek, licensed under the MIT License.
*
* Copyright (c) 2019-2024 PaperMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.api.response.v2;

import io.papermc.bibliothek.api.model.Change;
import io.papermc.bibliothek.api.model.Channel;
import io.papermc.bibliothek.api.model.Download;
import io.papermc.bibliothek.database.model.VersionEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.Instant;
import java.util.List;
import java.util.Map;

@Schema
public record BuildsResponse(
@Schema(name = "project_id", pattern = "[a-z]+", example = "paper")
String project_id,

@Schema(name = "project_name", example = "Paper")
String project_name,

@Schema(name = "version", pattern = VersionEntity.PATTERN, example = "1.18")
String version,

@Schema(name = "builds")
List<VersionBuild> builds
) {
@Schema
public record VersionBuild(
@Schema(name = "build", pattern = "\\d+", example = "10")
int build,

@Schema(name = "time")
Instant time,

@Schema(name = "channel")
Channel channel,

@Schema(name = "promoted")
boolean promoted,

@Schema(name = "changes")
List<Change> changes,

@Schema(name = "downloads")
Map<String, Download> downloads
) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* This file is part of bibliothek, licensed under the MIT License.
*
* Copyright (c) 2019-2024 PaperMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.api.response.v2;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;

@Schema
public record ProjectResponse(
@Schema(name = "project_id", pattern = "[a-z]+", example = "paper")
String project_id,

@Schema(name = "project_name", example = "Paper")
String project_name,

@Schema(name = "version_groups")
List<String> version_groups,

@Schema(name = "versions")
List<String> versions
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* This file is part of bibliothek, licensed under the MIT License.
*
* Copyright (c) 2019-2024 PaperMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package io.papermc.bibliothek.api.response.v2;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;

@Schema
public record ProjectsResponse(
@Schema(name = "projects")
List<String> projects
) {
}
Loading

0 comments on commit 8b1d897

Please sign in to comment.