501stLegionA3 / FiveOhFirstDataCore

A Web App designed to manage the 501st Legion StarSim Roster.
https://dc.501stlegion-a3.com/
MIT License
8 stars 12 forks source link

Add public api #409

Closed jdoxley closed 1 year ago

jdoxley commented 1 year ago

Make sure you familiarize yourself with our contributing guidelines.

Describe the PR

Add a public api for user info and billet info

Closes

Closes #408

Notes

Any other notes go here.

https://localhost:5001/api/userinfo?user=11345 results in:

{
    "nickName": "Del",
    "birthNumber": 11345,
    "lastPromotion": "2022-10-10T00:00:00",
    "lastBilletChange": "2022-10-17T00:00:00",
    "slot": "Avalanche 3-3",
    "role": "Squad Leader",
    "rank": "Sergeant",
    "qualifications": [
        "Zeus Permit",
        "RTO Qualified",
        "Marksman",
        "Grenadier",
        "Medic",
        "Jumpmaster",
        "Close Quarters Specalist"
    ],
    "tig": 14,
    "tib": 7
}

https://localhost:5001/api/billetinfo?enum=AvalancheThreeThree results in:

[
    {
        "displayName": "CS Del",
        "birthNumber": 11345
    },
    {
        "displayName": "CP Crebar",
        "birthNumber": 70303
    },
    {
        "displayName": "CP Klinger",
        "birthNumber": 54077
    },
    {
        "displayName": "CT Knight",
        "birthNumber": 56273
    },
    {
        "displayName": "CT Chimera",
        "birthNumber": 30253
    },
    {
        "displayName": "CM Deytow",
        "birthNumber": 23996
    },
    {
        "displayName": "CT Clover",
        "birthNumber": 14577
    },
    {
        "displayName": "CT Negeta",
        "birthNumber": 42361
    },
    {
        "displayName": "CM-C Bones",
        "birthNumber": 87071
    },
    {
        "displayName": "CI-C Soyvolon",
        "birthNumber": 42127
    },
    {
        "displayName": "CT Tal",
        "birthNumber": 17077
    }
]

https://localhost:5001/api/billetinfo?enum=AvalancheThreeThree&role=Trooper results in:

[
    {
        "displayName": "CT Clover",
        "birthNumber": 14577
    },
    {
        "displayName": "CT Negeta",
        "birthNumber": 42361
    },
    {
        "displayName": "CT Knight",
        "birthNumber": 56273
    },
    {
        "displayName": "CT Chimera",
        "birthNumber": 30253
    }
]
hobnob11 commented 1 year ago

pog

Soyvolon commented 1 year ago

Also! Please enable Swagger Gen. You may need an NuGet package for this, but here is an example config: https://github.com/Soyvolon/VirtualPDrive/blob/bba4dc9b2bdc344e2991bec8c2ffbadfe3e67a8b/VirtualPDrive.API/Startup.cs#L27-L43

edit:

oh and you will want this in your .csproj file;

<PropertyGroup>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>