Google Places · API Governance Rules

Google Places API Rules

Spectral linting rules defining API design standards and conventions for Google Places.

44 Rules error 6 warn 24 info 14
View Rules File View on GitHub

Rule Categories

error get info no openapi operation parameter path paths post query request response schema security servers tags

Rules

warn
info-title-google-places
The info.title must begin with "Google Places".
$.info.title
warn
info-description-required
A non-trivial info.description is required.
$.info
info
info-contact-required
Provider contact information should be present.
$.info
info
info-license-required
A license (Google APIs Terms of Service) should be declared.
$.info
warn
openapi-version-3-1
Specs must target OpenAPI 3.1.0.
$.openapi
error
servers-defined
At least one server must be defined.
$.servers
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
info
servers-places-host
The production server should be the Places API (New) host.
$.servers[*].url
warn
paths-no-trailing-slash
Paths must not end with a trailing slash.
$.paths[*]~
error
paths-no-query-string
Paths must not contain query strings.
$.paths[*]~
info
paths-places-prefix
All resource paths live under the /places collection.
$.paths[*]~
warn
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-google-places-prefix
Operation summaries must begin with "Google Places".
$.paths[*][get,post,put,patch,delete].summary
warn
operation-description-required
Every operation must have a description.
$.paths[*][get,post,put,patch,delete]
error
operation-operationId-required
Every operation must declare an operationId.
$.paths[*][get,post,put,patch,delete]
warn
operation-operationId-camelcase
operationId must be camelCase.
$.paths[*][get,post,put,patch,delete].operationId
info
operation-operationId-verb-prefix
operationId should start with a recognized verb (get, list, search, autocomplete, create, update, delete).
$.paths[*][get,post,put,patch,delete].operationId
warn
operation-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,patch,delete]
info
operation-microcks-extension
Each operation should carry an x-microcks-operation extension for mock-server compatibility.
$.paths[*][get,post,put,patch,delete]
warn
tags-global-defined
A global tags array must be defined.
$
warn
tags-title-case
Global tag names must use Title Case (e.g. "Places", "Search").
$.tags[*].name
info
tags-have-description
Global tags should include a description.
$.tags[*]
warn
parameter-description-required
Every parameter must have a description.
$.paths[*][get,post,put,patch,delete].parameters[*]
warn
parameter-schema-required
Every parameter must define a schema with a type.
$.paths[*][get,post,put,patch,delete].parameters[?(@.in)]
info
parameter-field-mask-required
Places API (New) requests require the X-Goog-FieldMask header; a reusable FieldMask parameter should be defined.
$.components.parameters
warn
request-body-json
Request bodies must offer an application/json media type.
$.paths[*][post,put,patch].requestBody.content
warn
post-has-request-body
POST operations (search, autocomplete) must declare a request body.
$.paths[*].post
error
response-2xx-required
Every operation must define a 2xx success response.
$.paths[*][get,post,put,patch,delete].responses
info
response-json-content
200 responses should return application/json.
$.paths[*][get,post,put,patch,delete].responses.200.content
info
response-error-schema-message
The Error schema should expose an error object carrying a message.
$.components.schemas.Error.properties.error.properties
warn
schema-property-camelcase
Schema property names must be camelCase, matching the Places API (New) convention.
$.components.schemas[*].properties[*]~
info
schema-top-level-description
Top-level component schemas should have a description.
$.components.schemas[*]
warn
schema-types-defined
Component schemas must declare a type.
$.components.schemas[*]
warn
security-global-defined
A global security requirement must be declared.
$
warn
security-schemes-defined
Security schemes must be defined in components.
$.components
info
security-api-key-header
The primary API key scheme should be the X-Goog-Api-Key header.
$.components.securitySchemes.ApiKeyAuth
error
get-no-request-body
GET operations must not declare a request body.
$.paths[*].get
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description
info
schema-examples-encouraged
Schema properties are encouraged to provide example values.
$.components.schemas[*].properties[?(@.type && @.type != 'object' && @.type != 'array')]
warn
path-params-casing
Path parameters should be camelCase (the dominant convention in this API).
$.paths[*].parameters[?(@.in=='path')].name
warn
query-params-casing
Query parameters should be camelCase (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
info
schema-properties-casing
Schema properties should be camelCase (the dominant convention in this API).
$.components.schemas[*].properties
warn
error-schema-defined
A shared error schema (Error) should be defined for error payloads.
$.components.schemas

Spectral Ruleset

Raw ↑
# google-places — Spectral ruleset (strengthened)
# Plain Spectral. Existing hand-authored rules preserved; measured rules added
# from this provider's own OpenAPI conventions by strengthen_ruleset.py,
# then self-validated against the spec.
#
# Provenance:
#   - servers-https-only: 100% of servers already https (error)
#   - servers-expected-domain: 1/1 servers on googleapis.com
#   - path-params-casing: camel @ 100% (n=3)
#   - query-params-casing: camel @ 100% (n=5)
#   - operationid-casing: camel @ 100% (n=5)
#   - schema-names-casing: pascal @ 100% (n=17)
#   - schema-properties-casing: camel @ 65% (n=74)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: Error
#   - merge: kept 39 existing, added 5 measured, upgraded 0
#   - added: path-params-casing, query-params-casing, schema-names-casing, schema-properties-casing, error-schema-defined
extends:
  - spectral:oas
rules:
  info-title-google-places:
    description: The info.title must begin with "Google Places".
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: ^Google Places
  info-description-required:
    description: A non-trivial info.description is required.
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy
  info-contact-required:
    description: Provider contact information should be present.
    severity: info
    given: $.info
    then:
      field: contact
      function: truthy
  info-license-required:
    description: A license (Google APIs Terms of Service) should be declared.
    severity: info
    given: $.info
    then:
      field: license
      function: truthy
  openapi-version-3-1:
    description: Specs must target OpenAPI 3.1.0.
    severity: warn
    given: $.openapi
    then:
      function: pattern
      functionOptions:
        match: ^3\.1\.
  servers-defined:
    description: At least one server must be defined.
    severity: error
    given: $.servers
    then:
      function: truthy
  servers-https-only:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  servers-places-host:
    description: The production server should be the Places API (New) host.
    severity: info
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: places\.googleapis\.com
  paths-no-trailing-slash:
    description: Paths must not end with a trailing slash.
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: .+/$
  paths-no-query-string:
    description: Paths must not contain query strings.
    severity: error
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: \?
  paths-places-prefix:
    description: All resource paths live under the /places collection.
    severity: info
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^/places
  operation-summary-required:
    description: Every operation must have a summary.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: truthy
  operation-summary-google-places-prefix:
    description: Operation summaries must begin with "Google Places".
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: ^Google Places
  operation-description-required:
    description: Every operation must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy
  operation-operationId-required:
    description: Every operation must declare an operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy
  operation-operationId-camelcase:
    description: operationId must be camelCase.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]+$
  operation-operationId-verb-prefix:
    description: operationId should start with a recognized verb (get, list, search, autocomplete, create,
      update, delete).
    severity: info
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: pattern
      functionOptions:
        match: ^(get|list|search|autocomplete|create|update|delete)
  operation-tags-required:
    description: Every operation must have at least one tag.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy
  operation-microcks-extension:
    description: Each operation should carry an x-microcks-operation extension for mock-server compatibility.
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: x-microcks-operation
      function: truthy
  tags-global-defined:
    description: A global tags array must be defined.
    severity: warn
    given: $
    then:
      field: tags
      function: truthy
  tags-title-case:
    description: Global tag names must use Title Case (e.g. "Places", "Search").
    severity: warn
    given: $.tags[*].name
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z]+( [A-Z][A-Za-z]+)*$
  tags-have-description:
    description: Global tags should include a description.
    severity: info
    given: $.tags[*]
    then:
      field: description
      function: truthy
  parameter-description-required:
    description: Every parameter must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: description
      function: truthy
  parameter-schema-required:
    description: Every parameter must define a schema with a type.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in)]
    then:
      field: schema
      function: truthy
  parameter-field-mask-required:
    description: Places API (New) requests require the X-Goog-FieldMask header; a reusable FieldMask parameter
      should be defined.
    severity: info
    given: $.components.parameters
    then:
      field: FieldMask
      function: truthy
  request-body-json:
    description: Request bodies must offer an application/json media type.
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content
    then:
      field: application/json
      function: truthy
  post-has-request-body:
    description: POST operations (search, autocomplete) must declare a request body.
    severity: warn
    given: $.paths[*].post
    then:
      field: requestBody
      function: truthy
  response-2xx-required:
    description: Every operation must define a 2xx success response.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '200'
      function: truthy
  response-json-content:
    description: 200 responses should return application/json.
    severity: info
    given: $.paths[*][get,post,put,patch,delete].responses.200.content
    then:
      field: application/json
      function: truthy
  response-error-schema-message:
    description: The Error schema should expose an error object carrying a message.
    severity: info
    given: $.components.schemas.Error.properties.error.properties
    then:
      field: message
      function: truthy
  schema-property-camelcase:
    description: Schema property names must be camelCase, matching the Places API (New) convention.
    severity: warn
    given: $.components.schemas[*].properties[*]~
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  schema-top-level-description:
    description: Top-level component schemas should have a description.
    severity: info
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  schema-types-defined:
    description: Component schemas must declare a type.
    severity: warn
    given: $.components.schemas[*]
    then:
      field: type
      function: truthy
  security-global-defined:
    description: A global security requirement must be declared.
    severity: warn
    given: $
    then:
      field: security
      function: truthy
  security-schemes-defined:
    description: Security schemes must be defined in components.
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  security-api-key-header:
    description: The primary API key scheme should be the X-Goog-Api-Key header.
    severity: info
    given: $.components.securitySchemes.ApiKeyAuth
    then:
    - field: in
      function: pattern
      functionOptions:
        match: ^header$
    - field: name
      function: pattern
      functionOptions:
        match: ^X-Goog-Api-Key$
  get-no-request-body:
    description: GET operations must not declare a request body.
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy
  schema-examples-encouraged:
    description: Schema properties are encouraged to provide example values.
    severity: info
    given: $.components.schemas[*].properties[?(@.type && @.type != 'object' && @.type != 'array')]
    then:
      field: example
      function: truthy
  path-params-casing:
    description: Path parameters should be camelCase (the dominant convention in this API).
    severity: warn
    given: $.paths[*].parameters[?(@.in=='path')].name
    then:
      function: casing
      functionOptions:
        type: camel
  query-params-casing:
    description: Query parameters should be camelCase (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: casing
      functionOptions:
        type: camel
  schema-names-casing:
    description: Component schema names should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.components.schemas
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: pascal
  schema-properties-casing:
    description: Schema properties should be camelCase (the dominant convention in this API).
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: camel
  error-schema-defined:
    description: A shared error schema (Error) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: Error
      function: truthy