Skip to content

Commit

Permalink
fix(oas): update aep-lib-go, add contact
Browse files Browse the repository at this point in the history
Updated aep-lib-go to pick up new OAS changes, and
support specifying a contact.
  • Loading branch information
toumorokoshi committed Jan 21, 2025
1 parent 6fa792d commit 819671b
Show file tree
Hide file tree
Showing 9 changed files with 403 additions and 211 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
main
terraform-provider-bookstore
terraform-provider-bookstore
3 changes: 3 additions & 0 deletions example/bookstore/v1/bookstore.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# normally this would be suffixed with the domain (.com)
name: "bookstore.example.com"
url: "http://localhost:8081"
contact:
name: "API support"
email: "aepsupport@aep.dev"
resources:
# example of a simple resource
- kind: "publisher"
Expand Down
68 changes: 57 additions & 11 deletions example/bookstore/v1/bookstore_openapi.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
{
"info": {
"title": "bookstore.example.com",
"description": "An API for bookstore.example.com",
"version": "version not set",
"contact": {
"name": "API support",
"email": "aepsupport@aep.dev"
}
},
"openapi": "3.1.0",
"servers": [
{
"url": "http://localhost:8081"
}
],
"info": {
"title": "bookstore.example.com",
"description": "An API for bookstore.example.com",
"version": "version not set"
},
"paths": {
"/isbns": {
"get": {
Expand Down Expand Up @@ -55,6 +59,15 @@
"post": {
"description": "Create method for isbn",
"operationId": "CreateIsbn",
"parameters": [
{
"name": "id",
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful response",
Expand Down Expand Up @@ -165,6 +178,15 @@
"post": {
"description": "Create method for publisher",
"operationId": "CreatePublisher",
"parameters": [
{
"name": "id",
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful response",
Expand Down Expand Up @@ -233,7 +255,7 @@
"200": {
"description": "Successful response",
"content": {
"application/json": {
"application/merge-patch+json": {
"schema": {
"$ref": "#/components/schemas/publisher"
}
Expand All @@ -243,7 +265,7 @@
},
"requestBody": {
"content": {
"application/json": {
"application/merge-patch+json": {
"schema": {
"$ref": "#/components/schemas/publisher"
}
Expand Down Expand Up @@ -386,6 +408,13 @@
"schema": {
"type": "string"
}
},
{
"name": "id",
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
Expand Down Expand Up @@ -472,7 +501,7 @@
"200": {
"description": "Successful response",
"content": {
"application/json": {
"application/merge-patch+json": {
"schema": {
"$ref": "#/components/schemas/book"
}
Expand All @@ -482,7 +511,7 @@
},
"requestBody": {
"content": {
"application/json": {
"application/merge-patch+json": {
"schema": {
"$ref": "#/components/schemas/book"
}
Expand Down Expand Up @@ -651,6 +680,13 @@
"schema": {
"type": "string"
}
},
{
"name": "id",
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
Expand Down Expand Up @@ -789,7 +825,15 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/book"
"type": "object",
"properties": {
"success": {
"type": "boolean"
}
},
"x-aep-field-numbers": {
"0": "success"
}
}
}
}
Expand All @@ -798,7 +842,9 @@
"requestBody": {
"content": {
"application/json": {
"schema": {}
"schema": {
"type": "object"
}
}
},
"required": true
Expand Down
39 changes: 33 additions & 6 deletions example/bookstore/v1/bookstore_openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ components:
plural: publishers
singular: publisher
info:
contact:
email: aepsupport@aep.dev
name: API support
description: An API for bookstore.example.com
title: bookstore.example.com
version: version not set
Expand Down Expand Up @@ -131,6 +134,11 @@ paths:
post:
description: Create method for isbn
operationId: CreateIsbn
parameters:
- in: query
name: id
schema:
type: string
requestBody:
content:
application/json:
Expand Down Expand Up @@ -197,6 +205,11 @@ paths:
post:
description: Create method for publisher
operationId: CreatePublisher
parameters:
- in: query
name: id
schema:
type: string
requestBody:
content:
application/json:
Expand Down Expand Up @@ -257,14 +270,14 @@ paths:
type: string
requestBody:
content:
application/json:
application/merge-patch+json:
schema:
$ref: '#/components/schemas/publisher'
required: true
responses:
"200":
content:
application/json:
application/merge-patch+json:
schema:
$ref: '#/components/schemas/publisher'
description: Successful response
Expand Down Expand Up @@ -333,6 +346,10 @@ paths:
required: true
schema:
type: string
- in: query
name: id
schema:
type: string
requestBody:
content:
application/json:
Expand Down Expand Up @@ -408,14 +425,14 @@ paths:
type: string
requestBody:
content:
application/json:
application/merge-patch+json:
schema:
$ref: '#/components/schemas/book'
required: true
responses:
"200":
content:
application/json:
application/merge-patch+json:
schema:
$ref: '#/components/schemas/book'
description: Successful response
Expand Down Expand Up @@ -495,6 +512,10 @@ paths:
required: true
schema:
type: string
- in: query
name: id
schema:
type: string
requestBody:
content:
application/json:
Expand Down Expand Up @@ -578,14 +599,20 @@ paths:
requestBody:
content:
application/json:
schema: {}
schema:
type: object
required: true
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/book'
properties:
success:
type: boolean
type: object
x-aep-field-numbers:
"0": success
description: Successful response
servers:
- url: http://localhost:8081
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
github.com/PuerkitoBio/purell v1.1.0 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/aep-dev/aep-lib-go v0.0.0-20250108173750-6d2a3948c035 // indirect
github.com/aep-dev/aep-lib-go v0.0.0-20250121233519-8bc026ce637e // indirect
github.com/aep-dev/terraform-provider-aep v0.0.0-20241112052633-f48d45460768 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
Expand Down
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ github.com/aep-dev/aep-lib-go v0.0.0-20250106205003-284e8a515296 h1:l9n7phYnixUH
github.com/aep-dev/aep-lib-go v0.0.0-20250106205003-284e8a515296/go.mod h1:M+h1D6T2uIUPelmaEsJbjR6JhqKsTlPX3lxp25zQQsk=
github.com/aep-dev/aep-lib-go v0.0.0-20250108173750-6d2a3948c035 h1:xezDLZiowdMu7Y/snQJtvR0bNKHwri77S0CEwkzNixA=
github.com/aep-dev/aep-lib-go v0.0.0-20250108173750-6d2a3948c035/go.mod h1:M+h1D6T2uIUPelmaEsJbjR6JhqKsTlPX3lxp25zQQsk=
github.com/aep-dev/aep-lib-go v0.0.0-20250120053507-bea8f15d57e0 h1:3muNvfQJC7CCsWrHDbj94pOReplNHSErGeFKa4vs1q0=
github.com/aep-dev/aep-lib-go v0.0.0-20250120053507-bea8f15d57e0/go.mod h1:M+h1D6T2uIUPelmaEsJbjR6JhqKsTlPX3lxp25zQQsk=
github.com/aep-dev/aep-lib-go v0.0.0-20250120055437-d86b75293789 h1:8l3Gs5q+GiCbLk9R8HH1qXHLszCeDKVFm5PKKzDTBOk=
github.com/aep-dev/aep-lib-go v0.0.0-20250120055437-d86b75293789/go.mod h1:M+h1D6T2uIUPelmaEsJbjR6JhqKsTlPX3lxp25zQQsk=
github.com/aep-dev/aep-lib-go v0.0.0-20250121231840-c83409ea8188 h1:WaJIpprOrdfgJNCJfE6Y5c747H6B+obGIm36epwhjGE=
github.com/aep-dev/aep-lib-go v0.0.0-20250121231840-c83409ea8188/go.mod h1:M+h1D6T2uIUPelmaEsJbjR6JhqKsTlPX3lxp25zQQsk=
github.com/aep-dev/aep-lib-go v0.0.0-20250121232515-a2a291f11702 h1:MgtMJpM68Ht3NrtghsLJ9iwazg74nOmVaZVpkI2X5nA=
github.com/aep-dev/aep-lib-go v0.0.0-20250121232515-a2a291f11702/go.mod h1:M+h1D6T2uIUPelmaEsJbjR6JhqKsTlPX3lxp25zQQsk=
github.com/aep-dev/aep-lib-go v0.0.0-20250121233519-8bc026ce637e h1:fwCEENQV0LVH/HEkn6Egznu9FzsifNwnIW7qoYvs5jw=
github.com/aep-dev/aep-lib-go v0.0.0-20250121233519-8bc026ce637e/go.mod h1:M+h1D6T2uIUPelmaEsJbjR6JhqKsTlPX3lxp25zQQsk=
github.com/aep-dev/terraform-provider-aep v0.0.0-20241112052633-f48d45460768 h1:b5fRfpIIsOsdsT2N1MsBxr0K/fZacCUlWp0uY9/BJzM=
github.com/aep-dev/terraform-provider-aep v0.0.0-20241112052633-f48d45460768/go.mod h1:sUuUJSkWTc4GBxp8GEZXCeEI38VMyuM5msPQ9BG0kMA=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
Expand Down
4 changes: 4 additions & 0 deletions parser/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ func ToAPI(s *schema.Service) (*api.API, error) {
}
return &api.API{
ServerURL: s.Url,
Contact: &api.Contact{
Name: s.Contact.Name,
Email: s.Contact.Email,
},
Name: s.Name,
Schemas: schemas,
Resources: resources,
Expand Down
Loading

0 comments on commit 819671b

Please sign in to comment.