SWAPI - Star Wars API · API Governance Rules
SWAPI - Star Wars API API Rules
Spectral linting rules defining API design standards and conventions for SWAPI - Star Wars API.
34 Rules
error 10
warn 19
info 5
Rule Categories
external
get
info
no
openapi
operation
parameter
paths
response
schema
servers
tag
Rules
warn
info-title-swapi-prefix
API title MUST begin with "SWAPI".
$.info.title
warn
info-description-required
API description MUST be present and non-trivial.
$.info
error
info-version-required
API version MUST be defined.
$.info
info
info-contact-required
A contact block (community channel) MUST be defined.
$.info
warn
info-license-required
A license SHOULD be declared (SWAPI is open source).
$.info
warn
openapi-version-3-0-x
OpenAPI version MUST be 3.0.x.
$.openapi
error
servers-defined
At least one server entry MUST be defined.
$.servers
error
servers-https
Every server URL MUST use HTTPS.
$.servers[*].url
warn
servers-have-description
Each server entry SHOULD have a description.
$.servers[*]
error
paths-lowercase
Path segments MUST be lowercase.
$.paths.*~
info
paths-plural-resources
Top-level resource collections SHOULD use plural nouns (films, people, planets, species, starships, vehicles).
$.paths.*~
error
paths-no-query-string
Paths MUST NOT include query strings.
$.paths.*~
error
operation-operationid-required
Every operation MUST have an operationId.
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-operationid-camelcase
operationId MUST be camelCase.
$.paths[*][get,post,put,patch,delete,head,options].operationId
error
operation-summary-required
Every operation MUST have a summary.
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-summary-title-case
Operation summaries SHOULD use Title Case.
$.paths[*][get,post,put,patch,delete,head,options].summary
warn
operation-description-required
Every operation MUST have a description.
$.paths[*][get,post,put,patch,delete,head,options]
error
operation-tags-required
Every operation MUST be tagged.
$.paths[*][get,post,put,patch,delete,head,options]
warn
tag-global-defined
Tags MUST be defined at the document root.
$
warn
tag-description-required
Each global tag SHOULD have a description.
$.tags[*]
warn
tag-title-case
Tag names MUST use Title Case.
$.tags[*].name
warn
parameter-description-required
Every parameter MUST have a description.
$.paths[*][*].parameters[*]
warn
parameter-snake-case
Parameter names SHOULD be snake_case (SWAPI convention is single-word lowercase, e.g. `search`, `page`, `id`).
$.paths[*][*].parameters[*].name
info
parameter-pagination-page
Pagination parameter MUST be named `page` (SWAPI convention).
$.paths[*][*].parameters[?(@.in=='query' && (@.name=='offset' || @.name=='limit' || @.name=='cursor'))]
error
response-success-required
Every operation MUST declare a 2xx response.
$.paths[*][*].responses
warn
response-404-required
GET operations on resource detail paths MUST declare a 404 response.
$.paths[?(@property.match(/\{id\}/))][get].responses
warn
response-description-required
Every response MUST have a description.
$.paths[*][*].responses[*]
warn
response-content-json
Responses with content SHOULD use application/json.
$.paths[*][*].responses[*].content
warn
schema-property-snake-case
Schema property names MUST be snake_case (the SWAPI wire format convention).
$.components.schemas[*].properties.*~
warn
schema-types-defined
Schema properties MUST declare a `type`.
$.components.schemas[*].properties[*]
info
schema-canonical-fields
Resource schemas MUST include `created`, `edited`, and `url` (SWAPI canonical envelope fields).
$.components.schemas[?(@property=='Film' || @property=='Person' || @property=='Planet' || @property=='Species' || @property=='Starship' || @property=='Vehicle')].properties
error
get-no-request-body
GET operations MUST NOT have a request body.
$.paths[*].get
warn
no-empty-descriptions
Descriptions MUST NOT be empty.
$..description
info
external-docs-encouraged
Top-level externalDocs SHOULD be defined.
$