diff --git a/src/app/[...slug]/page.tsx b/src/app/[...slug]/page.tsx
index a1597e60..332c42d1 100644
--- a/src/app/[...slug]/page.tsx
+++ b/src/app/[...slug]/page.tsx
@@ -76,7 +76,6 @@ export default async function Page({
projectName={projectName}
versionName={versionName}
specificationName={specificationName}
- user={user}
/>
),
}
diff --git a/src/lib/components/OpenApiSpecificationSelectorComponent.tsx b/src/lib/components/OpenApiSpecificationSelectorComponent.tsx
index b0c69f0e..92dcd8c6 100644
--- a/src/lib/components/OpenApiSpecificationSelectorComponent.tsx
+++ b/src/lib/components/OpenApiSpecificationSelectorComponent.tsx
@@ -11,19 +11,27 @@ import { useForceUpdate } from "../utils/Hooks";
interface OpenApiSpecificationSelectorComponentProps {
openApiSpecifications: IOpenApiSpecification[];
- openAPISpecification?: string;
+ openAPISpecification?: string;
+ versionName: string;
+ projectName: string;
}
const OpenApiSpecificationSelectorComponent: React.FC<
OpenApiSpecificationSelectorComponentProps
-> = ({ openApiSpecifications, openAPISpecification }) => {
+> = ({ openApiSpecifications, openAPISpecification, projectName, versionName }) => {
const router = useRouter();
+ const firstOpenAPISpecification = openApiSpecifications[0];
+ if (
+ (!openAPISpecification || openAPISpecification.length == 0) &&
+ firstOpenAPISpecification
+ ) {
+ router.push(
+ `/${projectName.replace("-openapi", "")}/${versionName}/${firstOpenAPISpecification.name}`
+ );
+ }
const handleVersionChange = (event: SelectChangeEvent) => {
const openApiSpecificationName = event.target.value;
- const openApiSpecification = openApiSpecifications.find(
- (x) => x.name === openApiSpecificationName
- );
router.push(`/${getProject()?.replace("-openapi", "")}/${getVersion()}/${openApiSpecificationName}`);
};
diff --git a/src/lib/components/OpenApiSpecificationsComponent.tsx b/src/lib/components/OpenApiSpecificationsComponent.tsx
index 17d357a9..26f1ef8e 100644
--- a/src/lib/components/OpenApiSpecificationsComponent.tsx
+++ b/src/lib/components/OpenApiSpecificationsComponent.tsx
@@ -6,7 +6,6 @@ import OpenApiSpecificationSelectorComponent from "./OpenApiSpecificationSelecto
interface OpenApiSpecificationsComponentProps {
versionName: string;
projectName: string;
- user: IUser;
openApiSpecificationRepository: IOpenApiSpecificationRepository;
specificationName?: string;
}
@@ -16,7 +15,6 @@ const OpenApiSpecificationsComponent: React.FC<
> = async ({
versionName,
openApiSpecificationRepository,
- user,
projectName,
specificationName,
}) => {
@@ -31,6 +29,8 @@ const OpenApiSpecificationsComponent: React.FC<
);
};
diff --git a/src/lib/components/VersionSelectorComponent.tsx b/src/lib/components/VersionSelectorComponent.tsx
index 657fc94c..75816207 100644
--- a/src/lib/components/VersionSelectorComponent.tsx
+++ b/src/lib/components/VersionSelectorComponent.tsx
@@ -12,17 +12,25 @@ import { useRouter } from "next/navigation";
interface VersionSelectorComponentProps {
versions: IVersion[];
version?: string;
+ projectName: string;
}
const VersionSelectorComponent: React.FC = ({
versions,
- version
+ version,
+ projectName,
}) => {
const router = useRouter();
+ const firstVersion = versions[0];
+ if ((!version || version.length == 0) && firstVersion) {
+ router.push(
+ `/${projectName?.replace("-openapi", "")}/${firstVersion.name}`
+ );
+ }
const handleVersionChange = (event: SelectChangeEvent) => {
const versionName = event.target.value;
- router.push(`/${getProject()!.replace("-openapi", "")}/${versionName}`);
+ router.push(`/${getProject()?.replace("-openapi", "")}/${versionName}`);
};
return (
diff --git a/src/lib/components/VersionsComponent.tsx b/src/lib/components/VersionsComponent.tsx
index 05690d13..a62b2d58 100644
--- a/src/lib/components/VersionsComponent.tsx
+++ b/src/lib/components/VersionsComponent.tsx
@@ -22,7 +22,13 @@ const VersionsComponent: React.FC = async ({
owner: "shapehq",
} as IGitHubProject);
- return ;
+ return (
+
+ );
};
export default VersionsComponent;
diff --git a/src/lib/projects/GitHubOpenAPISpecificationRepository.ts b/src/lib/projects/GitHubOpenAPISpecificationRepository.ts
index 6fe40a8b..f6c1214e 100644
--- a/src/lib/projects/GitHubOpenAPISpecificationRepository.ts
+++ b/src/lib/projects/GitHubOpenAPISpecificationRepository.ts
@@ -12,7 +12,7 @@ export class GitHubOpenApiSpecificationRepository implements IOpenApiSpecificati
}
async getOpenAPISpecifications(version: IGitHubVersion): Promise {
- const content = await this.gitHubClient.getContent(version.owner, version.repository)
+ const content = await this.gitHubClient.getContent(version.owner, version.repository, version.name)
return content.filter(e => {
return this.isOpenAPISpecification(e.name)
})