File size: 4,581 Bytes
7d0c16f
 
 
 
0324409
 
 
 
 
 
 
 
7d0c16f
 
 
 
0324409
 
 
7d0c16f
0324409
7d0c16f
 
0324409
 
 
 
 
 
 
 
 
 
7d0c16f
0324409
 
 
 
 
 
7d0c16f
0324409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7d0c16f
 
 
 
0324409
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7d0c16f
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
{% extends "base.html.j2" %}
{% import "components.html.j2" as ui %}

{% block content %}

<header class="doc-header">
  <h1>RESTlet 路 {{ doc.metadata.description or doc.metadata.script_type }}</h1>
  <p class="doc-header-meta">
    SuiteScript {{ doc.metadata.suitescript_version or "N/D" }}
  </p>
  <p class="muted">Documentaci贸n t茅cnica del servicio RESTlet.</p>
</header>

{{ ui.metadata_block(doc.metadata) }}
{{ ui.summary_block(doc.summary) }}

{# ============================================================
   ENDPOINTS (GET, POST, PUT, DELETE...)
   ============================================================ #}
{% set endpoints = doc.endpoints or {} %}
{% if endpoints and endpoints is mapping %}
  <div class="section">
    <h2>Endpoints</h2>

    {% for method, definition in endpoints.items() %}
      
      {# Saltar si la IA devolvi贸 algo no v谩lido #}
      {% if not (definition and definition is mapping) %}
        <h3>{{ method|upper }}</h3>
        <p>No se pudo interpretar la definici贸n de este endpoint.</p>
        {% continue %}
      {% endif %}

      <h3>{{ method|upper }}</h3>

      {% if definition.description %}
        <p>{{ definition.description }}</p>
      {% endif %}

      {# ---------------------- INPUTS ---------------------- #}
      {% set inputs = definition.inputs or {} %}
      {% if inputs is mapping %}

        {% if inputs.url_params %}
          {{ ui.table_block("URL params", inputs.url_params, [
            {"field": "name", "title": "Nombre"},
            {"field": "description", "title": "Descripci贸n"},
            {"field": "type", "title": "Tipo"}
          ]) }}
        {% endif %}

        {% if inputs.query_string %}
          {{ ui.table_block("Query string", inputs.query_string, [
            {"field": "name", "title": "Nombre"},
            {"field": "description", "title": "Descripci贸n"},
            {"field": "type", "title": "Tipo"}
          ]) }}
        {% endif %}

        {% if inputs.body_fields %}
          {{ ui.table_block("Body", inputs.body_fields, [
            {"field": "name", "title": "Nombre"},
            {"field": "description", "title": "Descripci贸n"},
            {"field": "type", "title": "Tipo"}
          ]) }}
        {% endif %}

      {% else %}
        <p class="muted">Inputs no estructurados o no disponibles.</p>
      {% endif %}

      {# ---------------------- L脫GICA ---------------------- #}
      {% if definition.logic %}
        {{ ui.logic_block("L贸gica", definition.logic) }}
      {% endif %}

      {# ---------------------- OPERACIONES ---------------------- #}
      {% if definition.record_operations %}
        {{ ui.table_block("Operaciones sobre registros", definition.record_operations, [
          {"field": "type", "title": "Operaci贸n"},
          {"field": "recordType", "title": "Record"},
          {"field": "details", "title": "Detalles"}
        ]) }}
      {% endif %}

      {% if definition.searches %}
        {{ ui.table_block("B煤squedas", definition.searches, [
          {"field": "id", "title": "ID"},
          {"field": "filters", "title": "Filtros"},
          {"field": "columns", "title": "Columnas"}
        ]) }}
      {% endif %}

      {# ---------------------- OUTPUT ---------------------- #}
      {% if definition.output %}
        {{ ui.logic_block("Salida", definition.output) }}
      {% endif %}

      {# ---------------------- VALIDACIONES ---------------------- #}
      {% if definition.validations %}
        {{ ui.list_block("Validaciones", definition.validations) }}
      {% endif %}

      {# ---------------------- SIDE EFFECTS ---------------------- #}
      {% if definition.side_effects %}
        {{ ui.list_block("Side effects", definition.side_effects) }}
      {% endif %}

    {% endfor %}
  </div>
{% endif %}

{# VALIDACIONES GLOBALES #}
{% if doc.validations %}
  {{ ui.list_block("Validaciones globales", doc.validations) }}
{% endif %}

{# ERRORES #}
{% if doc.errors %}
  {% if doc.errors is mapping %}
    {{ ui.list_block("Errores detectados", doc.errors.explicit_checks or []) }}
    {{ ui.list_block("Manejo de excepciones", doc.errors.exception_handling or []) }}
  {% else %}
    {{ ui.table_block("Errores", doc.errors, [
      {"field": "location", "title": "Ubicaci贸n"},
      {"field": "description", "title": "Descripci贸n"},
      {"field": "throws", "title": "Excepci贸n"}
    ]) }}
  {% endif %}
{% endif %}

{# SIDE EFFECTS GLOBALES #}
{% if doc.side_effects %}
  {{ ui.list_block("Side effects globales", doc.side_effects) }}
{% endif %}

{% endblock %}