メインコンテンツまでスキップ

Your First Number Content

Viron Content is a page child, serving mainly as a monitor to display an assigned operation's response data. A page can have multiple contents inside. A Viron content has a type property that influences how response data should be displayed. In this step, we will use the type of number.

Editing the OAS Document

Edit the example response body of the request GET /oas as follows:

{
"openapi": "3.0.2",
"info":{
"title": "RESTful Administration API Server for Viron",
"version": "mock",
"x-pages": [
{
"id": "page01",
"title": "Page One",
"group": "sample",
"contents": [
{
"type": "number",
"title": "My First Number Content",
"operationId": "getDAU"
}
]
},
{
"id": "page02",
"title": "Page Two",
"group": "sample",
"contents": []
}
],
"x-number": {
"responseKey": "value"
}
},
"paths": {
"/dau": {
"get": {
"operationId": "getDAU",
"responses": {
"200": {
"description": "Daily Active User",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"value": {
"type": "number"
}
}
}
}
}
}
}
}
}
}
}

Here we have added:

  • a Viron content to display the number of DAU on the page named Page One.
  • an OAS Path Item Object that defines how to fetch the DAU data.

The OAS document now says that the Viron content on the page should display the DAU number fetched by the operation named getDAU. Viron interprets the information and works accordingly.

Creating a New Request and Example Response

As Viron will try to send requests to fetch data in the way specified in the OAS document, we need to set up the Postman mock server to handle the requests. Create one with the data below:

For Request:

value
Name/dau
MethodGET
URL{{url}}/dau

For Example Response,

Name: Default

Content Type: JSON

Body:

{
"value": 12345
}

Response Headers:

keyvalue
access-control-allow-originhttps://viron.plus
access-control-allow-credentialstrue

Visit the Viron endpoint page and select Page One, and you will see the DAU number.

注記

Visit documentations for content and content-number for detail.