tech-talks/swr-api-hooks.md

2.9 KiB

title
SWR API Hooks (and other assorted magicks)

Okay but truly, what are you on about?

So, hopefully we've all seen a bit of swagger at one point or another

openapi: 3.0.1
info:
  title: ELT API
paths:
  /liens/count:
    get:
      tags:
      - Liens
      summary: "Get Count of Lien Summaries. Note: When a search param is provided\
        \ date filters are ignored."
      parameters:
      - name: filter
        in: query
        description: ""
        required: false
        schema:
          $ref: '#/components/schemas/BaseLiensFilter'
      responses:
        "200":
          content:
            text/plain:
              schema:
                type: integer
                format: int32
        "400":
          $ref: '#/components/responses/InvalidRequest'
      security:
      - Basic: []

  /yada-yada-yada:

Maybe,

a few times,

you've even clicked 'Try it Out'

               ┍━━━━━━━━━━━━┑
               │ Try it Out │
               ┕━━━━━━━━━━━━┙ 

Which is pretty nice in its own right.

You may have also noticed some generated typescript for the frontend:

generated/
├── apis
│   ├── AdminApi.ts
│   ├── index.ts
│   ├── LetterDataApi.ts
│   ├── LetterEventsApi.ts
│   ├── LettersApi.ts
│   ├── PacketDetailsApi.ts
│   ├── PacketsApi.ts
│   ├── PreferencesApi.ts
│   ├── SecondLettersApi.ts
│   └── SparklerDefaultApi.ts
├── index.ts
├── models
│   ├── AffiliateExclusion.ts
│   ├── DeletePacketRequestBody.ts
│   ├── DeselectedInterestsResponse.ts
│   ├── DeselectedInterest.ts
│   ├── DeselectedLetterRequestBody.ts
│   ├── EventId.ts
│   ├── EventLog.ts
│   ├── Event.ts
│   ├── FirmBook.ts
│   ├── GetEventLogsResponse.ts
│   ├── GetPreferencesResponse.ts
│   ├── GetResponse.ts
│   ├── index.ts
│   ├── LetterSummary.ts
│   ├── Letter.ts
│   ├── ListAffiliateExclusionsFilter.ts
│   ├── ListAffiliateExclusionsResponse.ts
│   ├── ListPacketsFilter.ts
│   ├── ListPacketsResponse.ts
│   ├── MailingAddress.ts
│   ├── Money.ts
│   ├── PacketDetailsData.ts
│   ├── PacketSummary.ts
│   ├── Packet.ts
│   ├── SecondLetterPacket.ts
│   ├── SecondLettersResponse.ts
│   ├── SecondLetter.ts
│   ├── User.ts
│   ├── UspsRre.ts
│   ├── ViolationResponse.ts
│   └── Violation.ts
├── openapitools.json
└── runtime.ts

However

With the power of