servers: - url: http://localhost:3000 openapi: "3.0.0" info: title: API GeoNames Node version: 1.0.4 description: Simple API for city and state CRUD operations. contact: name: Mario Costa email: mariojr.rcosta@gmail.com security: - basicAuth: [] paths: '/v1/state': get: tags: - "state" summary: Fetch all states parameters: - in: query name: name schema: type: "string" example: "Rio de Janeiro" required: false description: Full name for filtering. - in: query name: shortName schema: type: "string" example: "RJ" required: false description: Abbreviation for filtering. - in: query name: q schema: type: "string" example: "Rio" required: false description: Search by name or abbreviation (matches either). - in: query name: deleted schema: type: integer example: 1 required: false description: Flag to show deleted documents - in: query name: sort schema: type: string example: "name" required: false description: Flag to define field to sort on - in: query name: order schema: type: integer format: int32 example: 1 required: false description: Flag to define sort order (-1 descending and 1 ascending) responses: 200: description: State collection content: application/json: schema: $ref: "#/components/schemas/StateListOk" 429: description: Too Many Requests content: application/json: schema: $ref: '#/components/schemas/RateLimitError' post: tags: - state summary: Creates a state requestBody: description: State object content: application/json: schema: properties: name: type: string example: "Rio de Janeiro" required: true shortName: type: string example: "RJ" required: true responses: 422: description: Validation failure content: {} 201: description: Item successfully created content: application/json: schema: $ref: '#/components/schemas/EstateObject' '/v1/state/{id}': put: tags: - state summary: Updates a state requestBody: description: State object content: application/json: schema: properties: name: type: string example: "Rio de Janeiro" required: false shortName: type: string example: "RJ" required: false responses: 422: description: Validation failure content: {} 200: description: Item successfully updated content: application/json: schema: $ref: '#/components/schemas/EstateObject' delete: tags: - state summary: Flags a state as deleted responses: 200: description: Item successfully updated content: application/json: schema: $ref: '#/components/schemas/EstateObject' '/v1/city': get: tags: - city summary: Fetch all cities parameters: - in: query name: name schema: type: "string" example: "Rio de Janeiro" required: false description: Full name for filtering. - in: query name: stateId schema: type: "string" format: uuid example: "90e55853-16ca-49a9-90bd-1dee256ab233" required: false description: StateId for filtering. - in: query name: deleted schema: type: integer example: 1 required: false description: Flag to show deleted documents - in: query name: sort schema: type: string example: "name" required: false description: Flag to define field to sort on - in: query name: order schema: type: integer format: int32 example: 1 required: false description: Flag to define sort order (-1 descending and 1 ascending) responses: 200: description: City collection content: application/json: schema: $ref: "#/components/schemas/CityListOk" 429: description: Too Many Requests content: application/json: schema: $ref: '#/components/schemas/RateLimitError' post: tags: - city summary: Creates a city requestBody: description: City object content: application/json: schema: properties: name: type: string example: "Rio de Janeiro" required: true stateId: type: string format: uuid example: "90e55853-16ca-49a9-90bd-1dee256ab233" required: true responses: 422: description: Validation failure content: {} 201: description: Item successfully created content: application/json: schema: $ref: '#/components/schemas/CityObject' '/v1/city/{id}': put: tags: - city summary: Updates a city requestBody: description: City object content: application/json: schema: properties: name: type: string example: "Rio de Janeiro" required: false stateId: type: string format: uuid example: "90e55853-16ca-49a9-90bd-1dee256ab233" required: false responses: 422: description: Validation failure content: {} 200: description: Item successfully updated content: application/json: schema: $ref: '#/components/schemas/CityObject' delete: tags: - city summary: Flags a city as deleted responses: 200: description: Item successfully updated content: application/json: schema: $ref: '#/components/schemas/CityObject' components: securitySchemes: basicAuth: type: http scheme: basic schemas: RateLimitError: type: "object" properties: title: type: "string" example: "Too Many Requests" type: type: "string" format: "uri" example: "https://httpstatus.com/429" status: type: "integer" example: 429 detail: type: "string" example: "Sometimes You Just Have to Slow Down." StateListOk: type: "object" properties: _total_items: type: integer format: int32 _page: type: integer format: int32 _page_count: type: integer format: int32 _links: type: object properties: self: type: object properties: href: type: string example: "http://{{host}}/v1/state?page=1" _embedded: type: object properties: states: type: "array" items: $ref: '#/components/schemas/EstateObject' CityListOk: type: "object" properties: _total_items: type: integer format: int32 _page: type: integer format: int32 _page_count: type: integer format: int32 _links: type: object properties: self: type: object properties: href: type: string example: "http://{{host}}/v1/state?page=1" _embedded: type: object properties: states: type: "array" items: $ref: '#/components/schemas/CityObject' EstateObject: type: "object" properties: id: type: "string" format: "uuid" example: "90e55853-16ca-49a9-90bd-1dee256ab233" name: type: "string" format: "string" example: "Rio de Janeiro" shortName: type: "string" format: "string" example: "RJ" createdAt: type: string format: 'date-time' example: "2020-06-26T01:50:37-03:00" updatedAt: type: string format: 'date-time' example: "2020-06-26T01:50:37-03:00" deleted: type: boolean example: false deletedAt: type: string format: 'date-time' example: "2020-06-26T01:50:37-03:00" _links: type: object properties: self: type: object properties: href: type: string example: "http://{{host}}/v1/state/90e55853-16ca-49a9-90bd-1dee256ab233" CityObject: type: "object" properties: id: type: "string" format: "uuid" example: "90e55853-16ca-49a9-90bd-1dee256ab234" name: type: "string" format: "string" example: "Rio de Janeiro" stateId: type: string format: uuid example: "90e55853-16ca-49a9-90bd-1dee256ab233" createdAt: type: string format: 'date-time' example: "2020-06-26T01:50:37-03:00" updatedAt: type: string format: 'date-time' example: "2020-06-26T01:50:37-03:00" deleted: type: boolean example: false deletedAt: type: string format: 'date-time' example: "2020-06-26T01:50:37-03:00" _links: type: object properties: self: type: object properties: href: type: string example: "http://{{host}}/v1/state/90e55853-16ca-49a9-90bd-1dee256ab234"