Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Esta página
se aplica à Apigee e à Apigee híbrida.
O hub de API oferece um Spectral linter (validador) integrado que valida a especificação da OpenAPI da API. Assim que você adiciona uma especificação OpenAPI à versão da API, o validador, que é ativado por padrão, valida a especificação e relata as descobertas no console do Google Cloud.
Desativar validação da especificação
Por padrão, o linter está ativado. Para desativar o linter, no console do Google Cloud, acesse a página Hub de API > Configurações > Ações e, na seção Linting, desative a opção Linting.
Guia de estilo
Um guia de estilo é um conjunto de regras que usam o hub de API para validar uma especificação da OpenAPI.
O hub de API usa um guia de estilo padrão para validar as especificações da OpenAPI. Para conferir as regras do guia de estilo padrão, consulte Regras da OpenAPI.
Fazer upload de um novo guia de estilo
Console
Para fazer o upload de um novo guia de estilo, siga estas etapas:
Crie um novo estilo estendendo o guia de estilo padrão. Para mais
informações, consulte Criar um conjunto de regras.
No console do Google Cloud, acesse a página Hub da API > Configurações > Ações.
Na seção Linting, clique em Upload new style document.
Faça o upload do novo documento de estilo (criado na etapa 1) e clique em Salvar.
API REST
Para fazer upload de um novo guia de estilo para inspeção, envie uma solicitação PATCH para a seguinte API:
Para fazer o download do guia de estilo padrão usado pelo hub da API para inspeção, siga estas etapas:
No console do Google Cloud, acesse a página Hub da API > Configurações > Ações.
Na seção Linting, clique em Fazer o download do documento de estilo padrão. Essa ação faz o download do documento de estilo padrão para o sistema local.
Faça o download do guia de estilo mais recente
Console
Para fazer o download do guia de estilo usado pelo hub da API para inspeção, siga estas etapas:
No console do Google Cloud, acesse a página Hub da API > Configurações > Ações.
Na seção Linting, clique em Download last style document. Essa ação faz o download do documento de estilo padrão para o sistema local.
API REST
Para fazer o download do guia de estilo usado pelo hub de API para inspeção, envie uma solicitação GET para a API a seguir:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-28 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."]]