From 2bbf7722be3acb004598cb13cfd171c6bca622d4 Mon Sep 17 00:00:00 2001 From: Matias Perrone Date: Thu, 4 Dec 2025 20:27:20 +0000 Subject: [PATCH] fix: Repeated Company schema in OpenAPI --- app/Swagger/CompaniesSchemas.php | 55 +------------------- app/Swagger/Models/CompanySchema.php | 78 +++++++++++++++++----------- 2 files changed, 49 insertions(+), 84 deletions(-) diff --git a/app/Swagger/CompaniesSchemas.php b/app/Swagger/CompaniesSchemas.php index 58f630983..de6216e5a 100644 --- a/app/Swagger/CompaniesSchemas.php +++ b/app/Swagger/CompaniesSchemas.php @@ -6,59 +6,6 @@ // Companies Schemas -#[OA\Schema( - schema: "Company", - description: "Company", - properties: [ - new OA\Property(property: "id", type: "integer", example: 1), - new OA\Property(property: "created", type: "integer", format: "int64", description: "Creation timestamp (epoch)", example: 1234567890), - new OA\Property(property: "last_edited", type: "integer", format: "int64", description: "Last edit timestamp (epoch)", example: 1234567890), - new OA\Property(property: "name", type: "string", example: "Acme Corporation"), - new OA\Property(property: "url", type: "string", format: "uri", nullable: true, example: "https://www.acme.com"), - new OA\Property(property: "url_segment", type: "string", nullable: true, example: "acme-corporation"), - new OA\Property(property: "display_on_site", type: "boolean", example: true), - new OA\Property(property: "featured", type: "boolean", example: false), - new OA\Property(property: "city", type: "string", nullable: true, example: "San Francisco"), - new OA\Property(property: "state", type: "string", nullable: true, example: "California"), - new OA\Property(property: "country", type: "string", nullable: true, example: "United States"), - new OA\Property(property: "description", type: "string", nullable: true, example: "Leading technology company"), - new OA\Property(property: "industry", type: "string", nullable: true, example: "Technology"), - new OA\Property(property: "products", type: "string", nullable: true, example: "Cloud services, Software"), - new OA\Property(property: "contributions", type: "string", nullable: true, example: "OpenStack contributions"), - new OA\Property(property: "contact_email", type: "string", format: "email", nullable: true, example: "contact@acme.com"), - new OA\Property(property: "member_level", type: "string", nullable: true, example: "Platinum"), - new OA\Property(property: "admin_email", type: "string", format: "email", nullable: true, example: "admin@acme.com"), - new OA\Property(property: "color", type: "string", nullable: true, example: "#FF5733"), - new OA\Property(property: "logo", type: "string", format: "uri", nullable: true, example: "https://cdn.example.com/logo.png"), - new OA\Property(property: "big_logo", type: "string", format: "uri", nullable: true, example: "https://cdn.example.com/big_logo.png"), - new OA\Property(property: "overview", type: "string", nullable: true, example: "Company overview"), - new OA\Property(property: "commitment", type: "string", nullable: true, example: "Commitment to open source"), - new OA\Property(property: "commitment_author", type: "string", nullable: true, example: "John Doe, CEO"), - new OA\Property( - property: "sponsorships", - type: "array", - items: new OA\Items(oneOf: [ - new OA\Schema(type: "integer"), - new OA\Schema(ref: "#/components/schemas/SummitSponsorship"), - ]), - description: "Array of sponsorship IDs (only when relations=sponsorships)", - ), - new OA\Property( - property: "project_sponsorships", - type: "array", - items: new OA\Items(oneOf: [ - new OA\Schema(type: "integer"), - new OA\Schema(ref: "#/components/schemas/ProjectSponsorshipType"), - ]), - description: "Array of project sponsorship IDs (only when relations=project_sponsorships)", - ), - ], - type: "object" -)] -class CompanySchema -{ -} - #[OA\Schema( schema: "PaginatedCompaniesResponse", description: "Paginated response for Companies", @@ -136,4 +83,4 @@ class CompanyCreateRequestSchema )] class CompanyUpdateRequestSchema { -} \ No newline at end of file +} diff --git a/app/Swagger/Models/CompanySchema.php b/app/Swagger/Models/CompanySchema.php index 2657628df..39549e3a7 100644 --- a/app/Swagger/Models/CompanySchema.php +++ b/app/Swagger/Models/CompanySchema.php @@ -5,38 +5,56 @@ use OpenApi\Attributes as OA; + #[OA\Schema( - schema: 'Company', - type: 'object', + schema: "Company", + description: "Company", properties: [ - new OA\Property(property: 'id', type: 'integer', example: 1), - new OA\Property(property: 'created', type: 'integer', example: 1), - new OA\Property(property: 'last_edited', type: 'integer', example: 1), - new OA\Property(property: 'name', type: 'string'), - new OA\Property(property: 'url', type: 'string'), - new OA\Property(property: 'url_segment', type: 'string'), - new OA\Property(property: 'city', type: 'string'), - new OA\Property(property: 'state', type: 'string'), - new OA\Property(property: 'country', type: 'string'), - new OA\Property(property: 'description', type: 'string'), - new OA\Property(property: 'industry', type: 'string'), - new OA\Property(property: 'contributions', type: 'string'), - new OA\Property(property: 'member_level', type: 'string'), - new OA\Property(property: 'overview', type: 'string'), - new OA\Property(property: 'products', type: 'string'), - new OA\Property(property: 'commitment', type: 'string'), - new OA\Property(property: 'commitment_author', type: 'string'), - new OA\Property(property: 'logo', type: 'string'), - new OA\Property(property: 'big_logo', type: 'string'), - new OA\Property(property: 'color', type: 'string'), - new OA\Property(property: 'display_on_site', type: 'boolean'), - new OA\Property(property: 'featured', type: 'boolean'), - new OA\Property(property: 'contact_email', type: 'string'), - new OA\Property(property: 'admin_email', type: 'string'), - new OA\Property(property: 'sponsorships', type: 'array', items: new OA\Items(oneOf: [new OA\Schema(type: 'integer'), new OA\Schema(ref: '#/components/schemas/SummitSponsorship'),]), description: "SummitSponsorship, IDs when used as relationship, object when included in expand"), - new OA\Property(property: 'project_sponsorships', type: 'array', items: new OA\Items(oneOf: [new OA\Schema(type: 'integer'), new OA\Schema(ref: '#/components/schemas/ProjectSponsorshipType'),]), description: "ProjectSponsorshipType supported by the distribution, IDs when used as relationship, object when included in expand"), - ]) -] + new OA\Property(property: "id", type: "integer", example: 1), + new OA\Property(property: "created", type: "integer", format: "int64", description: "Creation timestamp (epoch)", example: 1234567890), + new OA\Property(property: "last_edited", type: "integer", format: "int64", description: "Last edit timestamp (epoch)", example: 1234567890), + new OA\Property(property: "name", type: "string", example: "Acme Corporation"), + new OA\Property(property: "url", type: "string", format: "uri", example: "https://www.acme.com"), + new OA\Property(property: "url_segment", type: "string", example: "acme-corporation"), + new OA\Property(property: "city", type: "string", example: "San Francisco"), + new OA\Property(property: "state", type: "string", example: "California"), + new OA\Property(property: "country", type: "string", example: "United States"), + new OA\Property(property: "description", type: "string", example: "Leading technology company"), + new OA\Property(property: "industry", type: "string", example: "Technology"), + new OA\Property(property: "contributions", type: "string", example: "OpenStack contributions"), + new OA\Property(property: "member_level", type: "string", example: "Platinum"), + new OA\Property(property: "overview", type: "string", example: "Company overview"), + new OA\Property(property: "products", type: "string", example: "Cloud services, Software"), + new OA\Property(property: "commitment", type: "string", example: "Commitment to open source"), + new OA\Property(property: "commitment_author", type: "string", example: "John Doe, CEO"), + new OA\Property(property: "logo", type: "string", format: "uri", example: "https://cdn.example.com/logo.png"), + new OA\Property(property: "big_logo", type: "string", format: "uri", example: "https://cdn.example.com/big_logo.png"), + new OA\Property(property: "color", type: "string", example: "#FF5733"), + new OA\Property(property: "display_on_site", type: "boolean", example: true), + new OA\Property(property: "featured", type: "boolean", example: false), + new OA\Property(property: "contact_email", type: "string", format: "email", example: "contact@acme.com"), + new OA\Property(property: "admin_email", type: "string", format: "email", example: "admin@acme.com"), + new OA\Property( + property: "sponsorships", + type: "array", + items: new OA\Items(oneOf: [ + new OA\Schema(type: "integer"), + new OA\Schema(ref: "#/components/schemas/SummitSponsorship"), + ]), + description: "Array of sponsorship IDs (only when relations=sponsorships)", + ), + new OA\Property( + property: "project_sponsorships", + type: "array", + items: new OA\Items(oneOf: [ + new OA\Schema(type: "integer"), + new OA\Schema(ref: "#/components/schemas/ProjectSponsorshipType"), + ]), + description: "Array of project sponsorship IDs (only when relations=project_sponsorships)", + ), + ], + type: "object" +)] class CompanySchema { }