API 허브는 API의 OpenAPI 사양의 유효성을 검사하는 기본 제공 스펙트럼 린터(검사기)를 제공합니다. OpenAPI 사양을 API 버전에 추가하면 검사기(기본적으로 사용 설정됨)가 사양의 유효성을 검사하고 Google Cloud 콘솔에서 발견 항목을 보고합니다.
사양 유효성 검사 사용 중지
기본적으로 린터는 사용 설정됩니다. 린터를 사용 중지하려면 Google Cloud 콘솔에서 API 허브 > 설정 > 작업 페이지로 이동한 후 린트 섹션에서 린트 작업 옵션을 사용 중지합니다.
스타일 가이드
스타일 가이드는 API 허브가 OpenAPI 사양의 유효성을 검사하는 규칙 집합입니다.
API 허브는 OpenAPI 사양의 유효성을 검사하는 데 기본 스타일 가이드를 사용합니다. 기본 스타일 가이드 규칙은 OpenAPI 규칙을 참조하세요.
새 스타일 가이드 업로드
콘솔
새 스타일 가이드를 업로드하려면 다음 단계를 따르세요.
기본 스타일 가이드를 확장하여 새 스타일을 만듭니다. 자세한 내용은 규칙 집합 만들기를 참조하세요.
Google Cloud 콘솔에서 API 허브 > 설정 > 작업 페이지로 이동합니다.
린트 작업 섹션에서 새 스타일 문서 업로드를 클릭합니다.
1단계에서 만든 새 스타일 문서를 업로드한 다음 저장을 클릭합니다.
REST API
린트 작업을 위한 새 스타일 가이드를 업로드하려면 다음 API에 대해 PATCH 요청을 실행합니다.
스타일 가이드에는 URL을 포함할 수 없습니다. 스타일 가이드를 만들고 업로드할 때 규칙 세트의 extends 속성에 URL을 포함하지 않아야 합니다. 예를 들어 extends: [spectral:oas", "https://mystyle.com/"] 속성 생성으로 인해 업로드가 실패할 수 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eAPI hub features an in-built Spectral linter that validates OpenAPI specifications, with linting enabled by default, and the terms \u003ccode\u003elinting\u003c/code\u003e and \u003ccode\u003evalidating\u003c/code\u003e used interchangeably.\u003c/p\u003e\n"],["\u003cp\u003eUsers can disable specification validation in the Google Cloud console under API hub settings.\u003c/p\u003e\n"],["\u003cp\u003eAPI hub uses a default style guide for OpenAPI validation, and users can create and upload custom style guides by extending the default one.\u003c/p\u003e\n"],["\u003cp\u003eThe default and the latest style guides can be downloaded from the Google Cloud console or through REST API calls.\u003c/p\u003e\n"],["\u003cp\u003eStyle guides uploaded are restricted to not include URLs in the \u003ccode\u003eextends\u003c/code\u003e property of the ruleset.\u003c/p\u003e\n"]]],[],null,["# Validate API specifications\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n|\n| **Preview\n| --- Apigee API hub linting feature**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nAPI hub provides an in-built [Spectral linter](https://stoplight.io/open-source/spectral) (validator)\nwhich validates your API's OpenAPI specification. Soon after you add an OpenAPI specification to your API version,\nthe validator (which is enabled by default) validates the specification, and reports the findings in the Google Cloud console.\n| **Note:** In this topic, the terms `linting` and `validating` are used interchangeably. Both these terms mean the same.\n\nDisable specification validation\n--------------------------------\n\nBy default, the linter is enabled. To disable the linter,\nin the Google Cloud console, go to the **API hub \\\u003e Settings \\\u003e Actions** page, and then in the **Linting** section,\ndisable the **Linting** option.\n\nStyle guide\n-----------\n\nA style guide is a set of rules against which API hub validates an OpenAPI specification.\nAPI hub uses a default style guide for validating the OpenAPI specifications. For\nthe default style guide rules, see [OpenAPI Rules](https://meta.stoplight.io/docs/spectral/4dec24461f3af-open-api-rules).\n| **Note:**To add your own custom rules, you must create a new style guide that extends the default style guide. After adding your custom rules in the new style guide, you must upload the new style guide in API hub.\n\n### Upload a new style guide\n\n### Console\n\nTo upload a new style guide, do the following steps:\n\n1. Create a new style by extending the default style guide. For more information, see [Create a ruleset](https://meta.stoplight.io/docs/spectral/01baf06bdd05a-create-a-ruleset).\n2. In the Google Cloud console, go to the **API hub \\\u003e Settings \\\u003e Actions** page.\n\n3. In the **Linting** section, click **Upload new style document**.\n4. Upload the new style document (created in step 1), and then click **Save**.\n\n### REST API\n\nTo upload a new style guide for linting, issue a `PATCH` request\nto the following API:\n`https://apihub.googleapis.com/v1/projects/`\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e`/locations/`\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e`/plugins/standard-linter/styleGuide?update_mask=contents`\n\nFor more information about the API, see [UpdateStyleGuide](/apigee/docs/reference/apis/apihub/rest/v1/projects.locations.plugins/updateStyleGuide).\n\nThe following example shows the API call to upload a style guide. \n\n```\ncurl \\\n-H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n-H \"Content-Type: application/json\" \\\n-d '{\"name\":\"projects/test-project-1/locations/us-central1/plugins/standard-linter/styleGuide\",\n\"contents\":{ \"contents\": \"ZXh0ZW5kczogWyJzcGVjdHJhbDpvYXMiXQo=\",\n \"mimeType\": \"text/yaml\"}}' \\ \n-X PATCH \\\nhttps://apihub.googleapis.com/v1/projects/test-project-1/locations/us-central1/plugins/standard-linter/styleGuide?update_mask=contents \n```\n\n### Download the default style guide\n\nTo download the default style guide used by API hub for linting,\ndo the following steps:\n\n1. In the Google Cloud console, go to the **API hub \\\u003e Settings \\\u003e Actions** page.\n\n2. In the **Linting** section, click **Download default style document**. This downloads the default style document to your local system.\n\n### Download the latest style guide\n\n### Console\n\nTo download the style guide that is currently used by API hub for linting,\ndo the following steps:\n\n1. In the Google Cloud console, go to the **API hub \\\u003e Settings \\\u003e Actions** page.\n\n2. In the **Linting** section, click **Download latest style document**. This downloads the default style document to your local system.\n\n### REST API\n\nTo download the style guide that is currently used by API hub for linting, issue a `GET` request\nto the following API:\n`https://apihub.googleapis.com/v1/projects/`\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e`/locations/`\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e`/plugins/standard-linter/styleGuide:contents`\n\nFor more information about the API, see [GetStyleGuide](/apigee/docs/reference/apis/apihub/rest/v1/projects.locations.plugins/getStyleGuide).\n\nThe following example shows the API call to download the current style guide. \n\n```\ncurl -X \\\nGET -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n https://apihub.googleapis.com/v1/projects/test-project-1/locations/us-central1/plugins/standard-linter/styleGuide:contents\n```\n\n### Limitations\n\nThe following limitations apply when creating and uploading custom style guides:\n\n- **No URLs in `extends` property** : Style guides can't contain URLs. Ensure that you don't include any URLs in the `extends` property of your ruleset when creating and uploading a style guide. For example, the following property construction might cause the upload to fail: `extends: [spectral:oas\", \"https://mystyle.com/\"]`.\n- **`functionsDir` not allowed** : The `functionsDir` property is not allowed in custom style guides. Spectral style guides with JavaScript will not be executed by API hub during the linting process.\n\n As a workaround, if you require the use of a custom style guide with JavaScript functions, perform the following steps:\n 1. Run [Spectral](https://stoplight.io/open-source/spectral) outside of API hub using your custom style guide.\n 2. Update the linting results in the `Lint` attribute of the specification file in API hub."]]