Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
OpenAPI | gRPC
Cloud Endpoints mendukung API yang dijelaskan menggunakan spesifikasi OpenAPI versi 2.0.
API Anda dapat diterapkan menggunakan framework REST yang tersedia secara publik seperti
Django atau Jersey.
Anda mendeskripsikan API dalam file JSON atau YAML yang disebut sebagai dokumen
OpenAPI. Halaman ini menjelaskan beberapa manfaat penggunaan OpenAPI,
menampilkan dokumen OpenAPI dasar, dan memberikan informasi tambahan
untuk membantu Anda memulai OpenAPI.
Manfaat
Salah satu manfaat utama menggunakan OpenAPI adalah untuk dokumentasi; setelah Anda
memiliki dokumen OpenAPI yang menjelaskan API, Anda dapat dengan mudah membuat
dokumentasi referensi untuk API.
Ada manfaat lain dari penggunaan OpenAPI. Misalnya, Anda dapat:
Buat library klien dalam puluhan bahasa.
Buat stub server.
Gunakan project untuk memverifikasi kepatuhan dan membuat sampel.
Struktur dasar dokumen OpenAPI
Dokumen OpenAPI menjelaskan
platform
REST API Anda, dan menentukan informasi seperti:
Nama dan deskripsi API.
Setiap endpoint (jalur) di API.
Cara pemanggil diautentikasi.
Jika Anda baru mengenal OpenAPI, lihat situs
struktur dasar Swagger, yang menyediakan contoh dokumen OpenAPI (juga disebut sebagai
spesifikasi Swagger) dan menjelaskan secara singkat setiap bagian file.
Dokumen OpenAPI dari
panduan memulai Endpoints
mengilustrasikan struktur dasar ini:
swagger:"2.0"info:title:"Airport Codes"description:"Get the name of an airport from its three-letter IATA code."version:"1.0.0"#Thisfieldwillbereplacedbythedeploy_api.shscript.host:"YOUR-PROJECT-ID.appspot.com"schemes:-"https"paths:"/airportName":get:description:"Get the airport name for a given IATA code."operationId:"airportName"parameters:-name:iataCodein:queryrequired:truetype:stringresponses:200:description:"Success."schema:type:string400:description:"The IATA code is invalid or missing."
Selain struktur dasar, file openapi.yaml dari contoh
kode yang digunakan dalam tutorial
menunjukkan:
Cara mengonfigurasi jalur untuk menggunakan
kunci API.
Bergantung pada bahasa yang Anda gunakan, Anda mungkin dapat membuat dokumen OpenAPI. Di Java, ada project open source untuk
Jersey
dan
Spring
yang dapat membuat dokumen OpenAPI dari anotasi. Ada juga
plugin Maven.
Untuk pengguna Python, flask-swagger
mungkin merupakan project yang menarik, dan
swagger-node-express
untuk developer Node.
Komunitas OpenAPI terus mengembangkan alat untuk membantu komposisi
(dan, untuk beberapa bahasa, pembuatan otomatis) dokumen OpenAPI. Lihat
situs Swagger
untuk mengetahui daftar lengkap alat dan integrasi.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-18 UTC."],[[["\u003cp\u003eOpenAPI is used to describe APIs, and it supports generating reference documentation, client libraries, and server stubs.\u003c/p\u003e\n"],["\u003cp\u003eAn OpenAPI document defines the API's name, description, endpoints, and authentication methods.\u003c/p\u003e\n"],["\u003cp\u003eOpenAPI documents can be written in JSON or YAML, illustrating how to configure API keys and security schemes for authentication.\u003c/p\u003e\n"],["\u003cp\u003eVarious tools and libraries can help compose and automatically generate OpenAPI documents for multiple languages, including Java, Python, and Node.\u003c/p\u003e\n"],["\u003cp\u003eThere are extensions to the OpenAPI specification available for Endpoints APIs, and a few configuration steps to follow.\u003c/p\u003e\n"]]],[],null,["# OpenAPI overview\n\nOpenAPI \\| gRPC\n\n\u003cbr /\u003e\n\nCloud Endpoints supports APIs that are described using version 2.0 of the\n[OpenAPI specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md).\nYour API can be implemented using any publicly available REST framework such as\n[Django](https://www.djangoproject.com/) or [Jersey](https://jersey.github.io/).\nYou describe your API in a `JSON` or `YAML` file referred to as an *OpenAPI\ndocument*. This page describes some of the benefits to using OpenAPI,\nshows a basic OpenAPI document, and provides additional information\nto help you get started with OpenAPI.\n\nBenefits\n--------\n\nOne of the primary benefits to using OpenAPI is for documentation; once you\nhave an OpenAPI document that describes your API, it is easy to generate\nreference documentation for your API.\n\nThere other benefits to using OpenAPI. For example, you can:\n\n- Generate client libraries in dozens of languages.\n- Generate server stubs.\n- Use projects to verify your conformance and to generate samples.\n\nBasic structure of an OpenAPI document\n--------------------------------------\n\nAn OpenAPI document describes the\n[surface](/endpoints/docs/openapi/glossary#surface)\nof your REST API, and defines information such as:\n\n- The name and description of the API.\n- The individual endpoints (paths) in the API.\n- How the callers are authenticated.\n\nIf you are new to OpenAPI, take a look at the\n[Swagger basic structure](https://swagger.io/docs/specification/2-0/basic-structure/)\nwebsite, which provides a sample OpenAPI document (also referred to as a\nSwagger specification) and briefly explains each section of the file.\nThe OpenAPI document from the\n[Endpoints quickstart](/endpoints/docs/deploy-api)\nillustrates this basic structure: \n\n```carbon\n swagger: \"2.0\"\n info:\n title: \"Airport Codes\"\n description: \"Get the name of an airport from its three-letter IATA code.\"\n version: \"1.0.0\"\n # This field will be replaced by the deploy_api.sh script.\n host: \"YOUR-PROJECT-ID.appspot.com\"\n schemes:\n - \"https\"\n paths:\n \"/airportName\":\n get:\n description: \"Get the airport name for a given IATA code.\"\n operationId: \"airportName\"\n parameters:\n -\n name: iataCode\n in: query\n required: true\n type: string\n responses:\n 200:\n description: \"Success.\"\n schema:\n type: string\n 400:\n description: \"The IATA code is invalid or missing.\"\n```\n\nIn addition to the basic structure, the `openapi.yaml` file from the sample\ncode used in the [tutorials](/endpoints/docs/openapi/tutorials)\nillustrates:\n\n- How to configure a path to use an [API key](/endpoints/docs/openapi/restricting-api-access-with-api-keys).\n- Various [security schemes](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#securitySchemeObject) for authentication.\n- [OpenAPI extensions](/endpoints/docs/openapi/openapi-extensions) available for Endpoints APIs.\n\nGenerating an OpenAPI document\n------------------------------\n\nDepending on what language you are using, you might be able to generate an\nOpenAPI document. In Java, there are open source projects for both\n[Jersey](https://jersey.github.io/)\nand\n[Spring](https://github.com/springfox/springfox)\nthat can generate an OpenAPI document from annotations. There is also a\n[Maven plugin](http://kongchen.github.io/swagger-maven-plugin/).\nFor Python users, [flask-swagger](https://github.com/gangverk/flask-swagger)\nmight be an interesting project, and\n[swagger-node-express](https://www.npmjs.com/package/swagger-node-express)\nfor Node developers.\n\nThe OpenAPI community is continually developing tools to help in the composition\n(and, for some languages, automatic generation) of OpenAPI documents. See the\n[Swagger website](http://swagger.io/open-source-integrations/)\nfor a complete list of tools and integrations.\n\nWhat's next\n-----------\n\n- [OpenAPI extensions](/endpoints/docs/openapi/openapi-extensions)\n- [Unsupported OpenAPI features](/endpoints/docs/openapi/openapi-limitations)\n- [Configuring Endpoints](/endpoints/docs/openapi/configure-endpoints)\n- [Deploying the Endpoints Configuration](/endpoints/docs/openapi/deploy-endpoints-config)"]]