Skip to content

Commit

Permalink
Improve swagger documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Feb 29, 2024
1 parent 8c20379 commit 293461c
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 60 deletions.
12 changes: 6 additions & 6 deletions CS2Interface/Data/InspectItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
using SteamKit2.GC.CSGO.Internal;

namespace CS2Interface {
internal sealed class InspectItem : Item {
public sealed class InspectItem : Item {
[JsonInclude]
[JsonPropertyName("iteminfo")]
internal CEconItemPreviewDataBlock ItemInfo { get; private init; }
internal string s;
internal string a;
internal string d;
internal string m;
public CEconItemPreviewDataBlock ItemInfo { get; private init; }
public string s;
public string a;
public string d;
public string m;

internal InspectItem(CMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockResponse item, ulong param_s, ulong param_a, ulong param_d, ulong param_m) {
ItemInfo = item.iteminfo;
Expand Down
12 changes: 6 additions & 6 deletions CS2Interface/Data/InventoryItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
using SteamKit2.GC.CSGO.Internal;

namespace CS2Interface {
internal sealed class InventoryItem : Item {
public sealed class InventoryItem : Item {
[JsonInclude]
[JsonPropertyName("iteminfo")]
internal CSOEconItem ItemInfo { get; private init; }
public CSOEconItem ItemInfo { get; private init; }

[JsonInclude]
[JsonPropertyName("attributes")]
[JsonConverter (typeof(AttributeConverter))]
internal Dictionary<string, IAttribute>? Attributes { get; private set; }
public Dictionary<string, IAttribute>? Attributes { get; private set; }

[JsonInclude]
[JsonPropertyName("position")]
internal uint? Position { get; private set; }
public uint? Position { get; private set; }

[JsonInclude]
[JsonPropertyName("casket_id")]
internal ulong? CasketID { get; private set; }
public ulong? CasketID { get; private set; }

[JsonInclude]
[JsonPropertyName("moveable")]
internal bool? Moveable { get; private set; }
public bool? Moveable { get; private set; }

public bool ShouldSerializeAttributes() => Attributes != null && ShouldSerializeAdditionalProperties;
public bool ShouldSerializePosition() => Position != null && ShouldSerializeAdditionalProperties;
Expand Down
64 changes: 32 additions & 32 deletions CS2Interface/Data/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,107 +4,107 @@
using SteamKit2;

namespace CS2Interface {
internal class Item {
internal uint DefIndex;
internal uint PaintIndex;
internal uint? StickerID;
internal uint? TintID;
internal uint? MusicID;
internal uint Quality;
internal uint Rarity;
internal uint Origin;
public class Item {
public uint DefIndex;
public uint PaintIndex;
public uint? StickerID;
public uint? TintID;
public uint? MusicID;
public uint Quality;
public uint Rarity;
public uint Origin;

[JsonInclude]
[JsonPropertyName("full_name")]
internal string? FullName { get; private set; }
public string? FullName { get; private set; }

[JsonInclude]
[JsonPropertyName("full_type_name")]
internal string? FullTypeName { get; private set; }
public string? FullTypeName { get; private set; }

[JsonInclude]
[JsonPropertyName("rarity_name")]
internal string? RarityName { get; private set; }
public string? RarityName { get; private set; }

[JsonInclude]
[JsonPropertyName("quality_name")]
internal string? QualityName { get; private set; }
public string? QualityName { get; private set; }

[JsonInclude]
[JsonPropertyName("origin_name")]
internal string? OriginName { get; private set; }
public string? OriginName { get; private set; }

[JsonInclude]
[JsonPropertyName("type_name")]
internal string? TypeName { get; private set; }
public string? TypeName { get; private set; }

[JsonInclude]
[JsonPropertyName("item_name")]
internal string? ItemName { get; private set; }
public string? ItemName { get; private set; }

[JsonInclude]
[JsonPropertyName("tool_name")]
internal string? ToolName { get; private set; }
public string? ToolName { get; private set; }

[JsonInclude]
[JsonPropertyName("tint_name")]
internal string? TintName { get; private set; }
public string? TintName { get; private set; }

[JsonInclude]
[JsonPropertyName("weapon_image_url")]
internal string? WeaponImageURL { get; private set; }
public string? WeaponImageURL { get; private set; }

[JsonInclude]
[JsonPropertyName("weapon_name")]
internal string? WeaponName { get; private set; }
public string? WeaponName { get; private set; }

[JsonInclude]
[JsonPropertyName("wear_name")]
internal string? WearName { get; private set; }
public string? WearName { get; private set; }

[JsonInclude]
[JsonPropertyName("wear")]
internal double? Wear { get; set; }
public double? Wear { get; set; }

[JsonInclude]
[JsonPropertyName("wear_min")]
internal float? WearMin { get; private set; }
public float? WearMin { get; private set; }

[JsonInclude]
[JsonPropertyName("wear_max")]
internal float? WearMax { get; private set; }
public float? WearMax { get; private set; }

[JsonInclude]
[JsonPropertyName("name_id")]
internal string? NameID { get; private set; }
public string? NameID { get; private set; }

[JsonInclude]
[JsonPropertyName("set_name_id")]
internal string? SetNameID { get; private set; }
public string? SetNameID { get; private set; }

[JsonInclude]
[JsonPropertyName("set_name")]
internal string? SetName { get; private set; }
public string? SetName { get; private set; }

[JsonInclude]
[JsonPropertyName("crate_name_id")]
internal string? CrateNameID { get; private set; }
public string? CrateNameID { get; private set; }

[JsonInclude]
[JsonPropertyName("crate_defindex")]
internal uint? CrateDefIndex { get; private set; }
public uint? CrateDefIndex { get; private set; }

[JsonInclude]
[JsonPropertyName("crate_supply_series")]
internal uint? CrateSupplySeries { get; private set; }
public uint? CrateSupplySeries { get; private set; }

[JsonInclude]
[JsonPropertyName("crate_name")]
internal string? CrateName { get; private set; }
public string? CrateName { get; private set; }

[JsonInclude]
[JsonPropertyName("defs")]
internal ItemData? ItemData { get; private set; }
public ItemData? ItemData { get; private set; }

protected static bool ShouldSerializeAdditionalProperties = true;
protected static bool ShouldSerializeDefs = true;
Expand Down
10 changes: 5 additions & 5 deletions CS2Interface/Data/ItemData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
using SteamKit2;

namespace CS2Interface {
internal class ItemData {
public class ItemData {
[JsonInclude]
[JsonPropertyName("item_def")]
internal ItemDef ItemDef { get; private init; }
public ItemDef ItemDef { get; private init; }

[JsonInclude]
[JsonPropertyName("paint_kit_def")]
internal ItemDef? PaintKitDef { get; private init; }
public ItemDef? PaintKitDef { get; private init; }

[JsonInclude]
[JsonPropertyName("sticker_kit_def")]
internal ItemDef? StickerKitDef { get; private init; }
public ItemDef? StickerKitDef { get; private init; }

[JsonInclude]
[JsonPropertyName("music_def")]
internal ItemDef? MusicDef { get; private init; }
public ItemDef? MusicDef { get; private init; }

public bool ShouldSerializeItemDef() => ItemDef != null;
public bool ShouldSerializePaintKitDef() => PaintKitDef != null;
Expand Down
2 changes: 1 addition & 1 deletion CS2Interface/Data/ItemDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using SteamKit2;

namespace CS2Interface {
internal class ItemDef {
public class ItemDef {
[JsonInclude]
[JsonPropertyName("defs")]
[JsonConverter(typeof(JsonListItemConverter<KeyValue, KVConverter>))]
Expand Down
19 changes: 9 additions & 10 deletions CS2Interface/Helpers/IAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@

namespace CS2Interface {
public abstract partial class IAttribute {
public abstract string Name { get; }
public abstract Type Type { get; }
internal abstract string Name { get; }
internal abstract Type Type { get; }

public abstract uint ToUInt32();
internal abstract uint ToUInt32();

public abstract float ToSingle();
internal abstract float ToSingle();

public override abstract string ToString();
}

public sealed class Attribute<TObject> : IAttribute where TObject : notnull {
public override string Name { get; }
public override Type Type { get => typeof(TObject); }
public TObject Value;
internal override string Name { get; }
internal override Type Type { get => typeof(TObject); }
internal TObject Value;

public Attribute(string name, TObject value) {
Name = name;
Value = value;
}

public override uint ToUInt32() => (uint) Convert.ChangeType(Value, typeof(uint));
public override float ToSingle() => (float) Convert.ChangeType(Value, typeof(float));

internal override uint ToUInt32() => (uint) Convert.ChangeType(Value, typeof(uint));
internal override float ToSingle() => (float) Convert.ChangeType(Value, typeof(float));
public override string ToString() => (string) Convert.ChangeType(Value, typeof(string));
}
}

0 comments on commit 293461c

Please sign in to comment.