Skip to content

Support base paths in api specs#12

Merged
Swolebrain merged 1 commit intomainfrom
support-basepath
Jun 16, 2025
Merged

Support base paths in api specs#12
Swolebrain merged 1 commit intomainfrom
support-basepath

Conversation

@Swolebrain
Copy link
Copy Markdown
Contributor

Enhance schema generator and cli tool to support basepaths in openapi v3 specs.

Copy link
Copy Markdown

@skladany skladany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits, typos, and improvements, but nothing blocking 🏃‍♂️

boolean: {type: 'Boolean' as const},
}
private static sanitizePath(pathStr: string): string {
const trimmed = pathStr.split('/')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to add a .map(segment => segment.trim()) here to avoid accidental white space end up in the sanitized path

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I know the CLI specifically says to enter a base-path ...but might it be worth checking for schema/host and stripping that out too (or generating an error at the CLI section)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is just for the path not for the full url. Trim is a good call

src/tools.ts Outdated
schemaV4: string;
}

export interface GenerageSchemaFromOpenApiSpecOptions {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: GenerageSchemaFromOpenApiSpecOptions -> GenerateSchemaFromOpenApiSpecOptions

const apiSpecFile = argv['api-spec'] as string;
const namespace = argv.namespace as string;
const mappingType = argv['mapping-type'] as MappingType;
const serverBasePath = typeof argv['base-path'] === 'string' ? argv['base-path'] : undefined;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: might this make more sense as just basePath to be consistent with CLI option base-path? (or change the option to server-base-path)

src/tools.ts Outdated
@@ -32,14 +44,42 @@ export class Tools {
* @param namespace cedar namespace for your application
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These (and other @param comments elsewhere) are no longer accurate since you're using an options object now

@Swolebrain Swolebrain merged commit a3d6576 into main Jun 16, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants