新增:打包编译功能

This commit is contained in:
李强
2024-06-18 12:46:57 +08:00
parent 1f81ac5854
commit 38bb65f9d5
137 changed files with 2481 additions and 6332 deletions

View File

@@ -0,0 +1,5 @@
{% load rest_framework %}
{% load static %}
<pre class="highlight javascript hide" data-language="javascript"><code>{% code html %}<!-- Load the JavaScript client library -->
<script src="{% static 'rest_framework/js/coreapi-0.1.1.js' %}"></script>
<script src="{% url 'api-docs:schema-js' %}"></script>{% endcode %}</code></pre>

View File

@@ -0,0 +1,15 @@
{% load rest_framework %}
<pre class="highlight javascript hide" data-language="javascript"><code>{% code javascript %}var coreapi = window.coreapi // Loaded by `coreapi.js`
var schema = window.schema // Loaded by `schema.js`
// Initialize a client
var client = new coreapi.Client()
// Interact with the API endpoint
var action = [{% if section_key %}"{{ section_key }}", {% endif %}"{{ link_key }}"]
{% if link.fields %}var params = {
{% for field in link.fields %} {{ field.name }}: ...{% if not loop.last %},{% endif %}
{% endfor %}}
{% endif %}client.action(schema, action{% if link.fields %}, params{% endif %}).then(function(result) {
// Return value is in 'result'
}){% endcode %}</code></pre>

View File

@@ -0,0 +1,3 @@
{% load rest_framework %}
<pre class="highlight python hide" data-language="python"><code>{% code bash %}# Install the Python client library
$ pip install coreapi{% endcode %}</code></pre>

View File

@@ -0,0 +1,13 @@
{% load rest_framework %}
<pre class="highlight python hide" data-language="python"><code>{% code python %}import coreapi
# Initialize a client & load the schema document
client = coreapi.Client()
schema = client.get("{{ document.url }}"{% if schema_format %}, format="{{ schema_format }}"{% endif %})
# Interact with the API endpoint
action = [{% if section_key %}"{{ section_key }}", {% endif %}"{{ link_key }}"]
{% if link.fields %}params = {
{% for field in link.fields %} "{{ field.name }}": ...{% if not loop.last %},{% endif %}
{% endfor %}}
{% endif %}result = client.action(schema, action{% if link.fields %}, params=params{% endif %}){% endcode %}</code></pre>

View File

@@ -0,0 +1,3 @@
{% load rest_framework %}
<pre class="highlight shell hide" data-language="shell"><code>{% code bash %}# Install the command line client
$ pip install coreapi-cli{% endcode %}</code></pre>

View File

@@ -0,0 +1,6 @@
{% load rest_framework %}
<pre class="highlight shell hide" data-language="shell"><code>{% code bash %}# Load the schema document
$ coreapi get {{ document.url }}{% if schema_format %} --format {{ schema_format }}{% endif %}
# Interact with the API endpoint
$ coreapi action {% if section_key %}{{ section_key }} {% endif %}{{ link_key|cut:"> " }}{% for field in link.fields %} -p {{ field.name }}=...{% endfor %}{% endcode %}</code></pre>