Generacion de docs
This commit is contained in:
96
docs/nfc-server/Generate activation label.yml
Normal file
96
docs/nfc-server/Generate activation label.yml
Normal file
@@ -0,0 +1,96 @@
|
||||
info:
|
||||
name: Generate an activation label
|
||||
type: http
|
||||
seq: 2
|
||||
|
||||
http:
|
||||
method: POST
|
||||
url: "{{baseUrl}}/nfc/generate"
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"cardId": "",
|
||||
"override": false
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
examples:
|
||||
- name: 200 Response
|
||||
description: Label generated or reused successfully
|
||||
request:
|
||||
url: "{{baseUrl}}/nfc/generate"
|
||||
method: POST
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"cardId": "",
|
||||
"override": false
|
||||
}
|
||||
response:
|
||||
status: 200
|
||||
statusText: OK
|
||||
headers:
|
||||
- name: Content-Type
|
||||
value: application/json
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"code": "",
|
||||
"label": "",
|
||||
"overriden": false,
|
||||
"reused": false
|
||||
}
|
||||
- name: 422 Response
|
||||
description: Validation error
|
||||
request:
|
||||
url: "{{baseUrl}}/nfc/generate"
|
||||
method: POST
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"cardId": "",
|
||||
"override": false
|
||||
}
|
||||
response:
|
||||
status: 422
|
||||
statusText: Unprocessable Entity
|
||||
headers:
|
||||
- name: Content-Type
|
||||
value: application/json
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"error": {
|
||||
"msg": "",
|
||||
"field": ""
|
||||
}
|
||||
}
|
||||
- name: 500 Response
|
||||
description: Internal server error
|
||||
request:
|
||||
url: "{{baseUrl}}/nfc/generate"
|
||||
method: POST
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"cardId": "",
|
||||
"override": false
|
||||
}
|
||||
response:
|
||||
status: 500
|
||||
statusText: Internal Server Error
|
||||
body:
|
||||
type: text
|
||||
data: ""
|
||||
34
docs/nfc-server/Health check.yml
Normal file
34
docs/nfc-server/Health check.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
info:
|
||||
name: Health check
|
||||
type: http
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: "{{baseUrl}}/health"
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
examples:
|
||||
- name: 200 Response
|
||||
description: Server is healthy
|
||||
request:
|
||||
url: "{{baseUrl}}/health"
|
||||
method: GET
|
||||
response:
|
||||
status: 200
|
||||
statusText: OK
|
||||
headers:
|
||||
- name: Content-Type
|
||||
value: application/json
|
||||
body:
|
||||
type: json
|
||||
data: |-
|
||||
{
|
||||
"ok": false
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Local development server
|
||||
variables:
|
||||
- name: baseUrl
|
||||
value: http://localhost:3000
|
||||
90
docs/nfc-server/openapi.yaml
Normal file
90
docs/nfc-server/openapi.yaml
Normal file
@@ -0,0 +1,90 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: SF NFC Server API
|
||||
description: API for managing NFC card activation codes.
|
||||
version: 1.0.0
|
||||
servers:
|
||||
- url: http://localhost:3000
|
||||
description: Local development server
|
||||
|
||||
paths:
|
||||
/health:
|
||||
get:
|
||||
summary: Health check
|
||||
responses:
|
||||
'200':
|
||||
description: Server is healthy
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
ok:
|
||||
type: boolean
|
||||
|
||||
/nfc/generate:
|
||||
post:
|
||||
summary: Generate an activation label for an NFC card
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GenerateLabelRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: Label generated or reused successfully
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CodeGenerationResult'
|
||||
'422':
|
||||
description: Validation error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
'500':
|
||||
description: Internal server error
|
||||
|
||||
components:
|
||||
schemas:
|
||||
GenerateLabelRequest:
|
||||
type: object
|
||||
required:
|
||||
- cardId
|
||||
properties:
|
||||
cardId:
|
||||
type: string
|
||||
description: Unique identifier for the NFC card
|
||||
override:
|
||||
type: boolean
|
||||
description: Whether to force generation of a new code even if one exists
|
||||
default: false
|
||||
|
||||
CodeGenerationResult:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
description: The activation code
|
||||
label:
|
||||
type: string
|
||||
description: The generated label content (e.g., HTML/SVG)
|
||||
overriden:
|
||||
type: boolean
|
||||
description: True if an existing code was overridden
|
||||
reused:
|
||||
type: boolean
|
||||
description: True if an existing code was reused
|
||||
|
||||
ErrorResponse:
|
||||
type: object
|
||||
properties:
|
||||
error:
|
||||
type: object
|
||||
properties:
|
||||
msg:
|
||||
type: string
|
||||
field:
|
||||
type: string
|
||||
@@ -2,7 +2,6 @@ import type { ServerContext } from "domain/ServerContext.js";
|
||||
import type { NfcUsecases } from "./Nfc.usecases.js";
|
||||
import type { Request, Response } from "express"
|
||||
import { baseValidator } from "./validators.js";
|
||||
import { error } from "node:console";
|
||||
|
||||
export class NfcController {
|
||||
private ctx: ServerContext;
|
||||
@@ -17,7 +16,7 @@ export class NfcController {
|
||||
}
|
||||
|
||||
public generateActivationTag() {
|
||||
return (req: Request, res: Response) => {
|
||||
return async (req: Request, res: Response) => {
|
||||
const body = req.body
|
||||
const validate = baseValidator.validate(body)
|
||||
|
||||
@@ -28,6 +27,17 @@ export class NfcController {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const { card_id, override } = body.card_id
|
||||
const pormUsecase = this.nfcUsecases.generateActivationLabel()
|
||||
const useCaseRes = await pormUsecase({ card_id, override })
|
||||
|
||||
if (useCaseRes.error != undefined) {
|
||||
res.status(500).json({
|
||||
error: useCaseRes.error
|
||||
})
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user