Skip to content

Commit

Permalink
Auto generate spec JSON at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
SniperBuddy101 committed Oct 8, 2023
1 parent 6485a0f commit efc9b1f
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions apps/server/scripts/generate-openapi-spec-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default async function generateOpenAPISchemaJSON() {
.build();
const document = SwaggerModule.createDocument(app, config);
const outputPath = path.join(__dirname, "../../../docs/");
const outputFilePath = path.join(outputPath, "open-api-spec.json");
fs.writeFileSync(outputFilePath, JSON.stringify(document, null, 2));
console.log("Generated swagger file");
const outputFilePath = path.join(outputPath, "openapi.json");
fs.writeFileSync(outputFilePath, JSON.stringify(document));
console.log("Generated OpenAPI spec");
process.exit(0);
}

Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/cache/retrieve-cached-request.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
openapi: post /api/cache/v1/request/retrieve
openapi: post /cache/v1/request/retrieve
---
2 changes: 1 addition & 1 deletion docs/api-reference/cache/save-request-to-cache.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
openapi: post /api/cache/v1/request/save
openapi: post /cache/v1/request/save
---
2 changes: 1 addition & 1 deletion docs/api-reference/health/performs-a-health-check.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
openapi: get /api/healthz
openapi: get /healthz
---
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
openapi: get /api/prompts/v2/deployment
openapi: get /prompts/v2/deployment
---
2 changes: 1 addition & 1 deletion docs/api-reference/reporting/report-a-request.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
openapi: post /api/reporting/v2/request
openapi: post /reporting/v2/request
---
4 changes: 2 additions & 2 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@
}
},
"api": {
"baseUrl": "https://api.staging.pezzo.ai",
"baseUrl": "https://api.staging.pezzo.ai/api",
"playground": {
"mode": "hide"
}
},
"openapi": "https://api.staging.pezzo.ai/api/spec-json"
"openapi": "./openapi.json"
}
1 change: 1 addition & 0 deletions docs/openapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"openapi":"3.0.0","paths":{"/healthz":{"get":{"operationId":"HealthController_healthz","summary":"Performs a health check","parameters":[],"responses":{"200":{"description":"Returns the health status and current version"}},"tags":["Health"]}},"/prompts/v2/deployment":{"get":{"operationId":"PromptsController_getPromptDeployment","summary":"Get the deployed Prompt Version to a particular Environment","parameters":[{"name":"name","required":true,"in":"query","description":"The name of the prompt (case sensitive)","example":"PromptName","schema":{"type":"string"}},{"name":"environmentName","required":true,"in":"query","description":"The name of the environment (case sensitive)","example":"Production","schema":{"type":"string"}}],"responses":{"200":{"description":"Deployed prompt version object"},"404":{"description":"Prompt deployment not found for the specific environment name"},"500":{"description":"Internal server error"}},"tags":["Prompts"]}},"/reporting/v2/request":{"post":{"operationId":"ReportingController_reportRequest","summary":"Report a request","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateReportDto"}}}},"responses":{"200":{"description":"Report has been reported successfully"},"500":{"description":"Internal server error"}},"tags":["Reporting"]}},"/cache/v1/request/retrieve":{"post":{"operationId":"CacheController_retrieveCachedRequest","summary":"Retrieve cached request","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetrieveCacheRequestDto"}}}},"responses":{"200":{"description":"Returns the cached request data."},"404":{"description":"Cached request not found."}},"tags":["Cache"]}},"/cache/v1/request/save":{"post":{"operationId":"CacheController_saveRequestToCache","summary":"Save request to cache","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CacheRequestDto"}}}},"responses":{"200":{"description":"Returns the cache request result."}},"tags":["Cache"]}}},"info":{"title":"Pezzo API","description":"Specification of the Pezzo REST API, used by various clients.","version":"1.0","contact":{}},"tags":[],"servers":[],"components":{"schemas":{"PromptExecutionMetadataDto":{"type":"object","properties":{"provider":{"type":"string","description":"LLM provider","enum":["OpenAI","Azure","Anthropic"]},"client":{"type":"string","description":"Client name identifier","example":"pezzo-ts"},"clientVersion":{"type":"string","description":"Client version","example":"0.4.11"},"environment":{"type":"string","description":"The name of the Environment (case sensitive)","example":"Production"},"promptId":{"type":"string","description":"The ID of the reported prompt (if managed)","example":"c41jd0s93j000ud7kg7vekhi3"}},"required":["provider","client","clientVersion","environment"]},"ExecutionRequestDto":{"type":"object","properties":{"timestamp":{"format":"date-time","type":"string","description":"Request timestamp","example":"2021-01-01T00:00:00.000Z"},"body":{"type":"object","description":"Raw request body, as sent to the LLM","additionalProperties":true}},"required":["timestamp","body"]},"ExecutionResponseDto":{"type":"object","properties":{"timestamp":{"format":"date-time","type":"string","description":"Response timestamp","example":"2021-01-01T00:00:00.000Z"},"body":{"type":"object","description":"Raw response body, as received from the LLM","additionalProperties":true}},"required":["timestamp","body"]},"CreateReportDto":{"type":"object","properties":{"metadata":{"description":"Metadata","allOf":[{"$ref":"#/components/schemas/PromptExecutionMetadataDto"}]},"properties":{"type":"object","description":"Additional properties to be associated with the report","additionalProperties":true,"example":{"userId":"someUserId","traceId":"traceId"}},"request":{"$ref":"#/components/schemas/ExecutionRequestDto"},"response":{"$ref":"#/components/schemas/ExecutionResponseDto"},"cacheEnabled":{"type":"boolean","description":"Whether caching is enabled for the report","default":false},"cacheHit":{"type":"boolean","description":"Whether the report was generated from a cache hit or not","default":false}},"required":["metadata","request","response"]},"RetrieveCacheRequestDto":{"type":"object","properties":{"request":{"type":"object","description":"The request object to retrieve from cache","additionalProperties":true,"example":{"key1":"value1","key2":"value2"}}},"required":["request"]},"CacheRequestDto":{"type":"object","properties":{"request":{"type":"object","description":"The request object to cache","additionalProperties":true,"example":{"key1":"value1","key2":"value2"}},"response":{"type":"object","description":"The response object to cache","additionalProperties":true,"example":{"key1":"value1","key2":"value2"}}},"required":["request","response"]}}}}

0 comments on commit efc9b1f

Please sign in to comment.