diff --git a/.mock/definition/api.yml b/.mock/definition/api.yml new file mode 100644 index 0000000..79b09a9 --- /dev/null +++ b/.mock/definition/api.yml @@ -0,0 +1,4 @@ +name: generator-exec +error-discrimination: + strategy: property + property-name: error diff --git a/.mock/definition/backcompat.yml b/.mock/definition/backcompat.yml new file mode 100644 index 0000000..4007b21 --- /dev/null +++ b/.mock/definition/backcompat.yml @@ -0,0 +1,46 @@ +imports: + config: config.yml +types: + BackwardsCompatibleGeneratorConfig: + properties: + dryRun: boolean + irFilepath: string + output: BackwardsCompatibleGeneratorOutputConfig + publish: + type: optional + docs: Deprecated. Use output.mode instead. + workspaceName: string + organization: string + customConfig: unknown + environment: config.GeneratorEnvironment + BackwardsCompatibleGeneratorOutputConfig: + properties: + path: string + mode: BackwardsCompatibleOutputMode + BackwardsCompatibleOutputMode: + union: + publish: BackwardsCompatGeneratorPublishConfig + downloadFiles: {} + github: config.GithubOutputMode + BackwardsCompatGeneratorPublishConfig: + docs: For the TS generators that use strict parsing. + properties: + registries: + type: config.GeneratorRegistriesConfig + docs: Deprecated, use publishTargets instead. + registriesV2: + type: BackwardsCompatibleRegistriesConfigV2 + docs: Deprecated, use publishTargets instead. + publishTarget: + type: optional + docs: Must always be TS for TypeScript + version: string + BackwardsCompatibleRegistriesConfigV2: + docs: For the ts generators that are not backwards compatible. + properties: + maven: config.MavenRegistryConfigV2 + npm: config.NpmRegistryConfigV2 + pypi: config.PypiRegistryConfig + BackwardsCompatiblePublishTarget: + union: + npm: config.NpmRegistryConfigV2 diff --git a/.mock/definition/config.yml b/.mock/definition/config.yml new file mode 100644 index 0000000..8173271 --- /dev/null +++ b/.mock/definition/config.yml @@ -0,0 +1,228 @@ +imports: + logging: logging.yml +types: + GeneratorConfig: + properties: + dryRun: boolean + irFilepath: string + originalReadmeFilepath: optional + license: optional + output: GeneratorOutputConfig + publish: + type: optional + docs: Deprecated. Use output.mode instead. + workspaceName: string + organization: string + customConfig: unknown + environment: GeneratorEnvironment + whitelabel: boolean + writeUnitTests: boolean + generatePaginatedClients: optional + generateOauthClients: boolean + LicenseConfig: + union: + basic: BasicLicense + custom: CustomLicense + BasicLicense: + properties: + id: LicenseId + LicenseId: + enum: + - MIT + - name: apache2 + value: Apache-2.0 + CustomLicense: + properties: + filename: string + GeneratorOutputConfig: + properties: + path: string + snippetFilepath: optional + snippetTemplateFilepath: optional + publishingMetadata: optional + mode: OutputMode + OutputMode: + union: + publish: GeneratorPublishConfig + downloadFiles: {} + github: GithubOutputMode + GeneratorPublishConfig: + properties: + registries: + type: GeneratorRegistriesConfig + docs: Deprecated, use publishTargets instead. + registriesV2: + type: GeneratorRegistriesConfigV2 + docs: Deprecated, use publishTargets instead. + publishTarget: optional + version: string + GithubOutputMode: + properties: + version: string + repoUrl: + type: string + docs: A full repo url (i.e. https://github.com/fern-api/fern) + installationToken: + type: optional + docs: > + The token scoped to installing the repository. If not specified, the + generator + + should NOT attempt to clone the repository. + publishInfo: optional + OutputMetadataAuthor: + properties: + name: string + email: string + OutputMetadata: + properties: + description: optional + authors: optional> + PublishingMetadata: + docs: >- + This should effectively be deprecated in favor of a more specific + configuration per-output mode (pypi, maven, etc.). + properties: + package_description: optional + publisher_email: optional + reference_url: optional + publisher_name: optional + GithubPublishInfo: + union: + npm: NpmGithubPublishInfo + maven: MavenGithubPublishInfo + postman: PostmanGithubPublishInfo + pypi: PypiGithubPublishInfo + rubygems: RubyGemsGithubPublishInfo + nuget: NugetGithubPublishInfo + EnvironmentVariable: string + NpmGithubPublishInfo: + properties: + registryUrl: string + packageName: string + tokenEnvironmentVariable: EnvironmentVariable + shouldGeneratePublishWorkflow: optional + MavenCentralSignatureGithubInfo: + properties: + keyIdEnvironmentVariable: EnvironmentVariable + passwordEnvironmentVariable: EnvironmentVariable + secretKeyEnvironmentVariable: EnvironmentVariable + MavenGithubPublishInfo: + properties: + registryUrl: string + coordinate: string + usernameEnvironmentVariable: EnvironmentVariable + passwordEnvironmentVariable: EnvironmentVariable + signature: optional + shouldGeneratePublishWorkflow: optional + PostmanGithubPublishInfo: + properties: + apiKeyEnvironmentVariable: EnvironmentVariable + workspaceIdEnvironmentVariable: EnvironmentVariable + PypiMetadata: + extends: OutputMetadata + properties: + keywords: optional> + documentationLink: optional + homepageLink: optional + PypiGithubPublishInfo: + properties: + registryUrl: string + packageName: string + usernameEnvironmentVariable: EnvironmentVariable + passwordEnvironmentVariable: EnvironmentVariable + pypiMetadata: optional + shouldGeneratePublishWorkflow: optional + RubyGemsGithubPublishInfo: + properties: + registryUrl: string + packageName: string + apiKeyEnvironmentVariable: EnvironmentVariable + shouldGeneratePublishWorkflow: optional + NugetGithubPublishInfo: + properties: + registryUrl: string + packageName: string + apiKeyEnvironmentVariable: EnvironmentVariable + shouldGeneratePublishWorkflow: optional + GeneratorRegistriesConfig: + properties: + maven: MavenRegistryConfig + npm: NpmRegistryConfig + MavenCentralSignature: + properties: + keyId: string + password: string + secretKey: string + MavenRegistryConfig: + properties: + registryUrl: string + username: string + password: string + group: string + signature: optional + NpmRegistryConfig: + properties: + registryUrl: string + token: string + scope: string + GeneratorRegistriesConfigV2: + properties: + maven: MavenRegistryConfigV2 + npm: NpmRegistryConfigV2 + pypi: PypiRegistryConfig + rubygems: RubyGemsRegistryConfig + nuget: NugetRegistryConfig + GeneratorPublishTarget: + union: + maven: MavenRegistryConfigV2 + npm: NpmRegistryConfigV2 + pypi: PypiRegistryConfig + postman: PostmanConfig + rubygems: RubyGemsRegistryConfig + nuget: NugetRegistryConfig + MavenRegistryConfigV2: + properties: + registryUrl: string + username: string + password: string + coordinate: string + signature: optional + NpmRegistryConfigV2: + properties: + registryUrl: string + token: string + packageName: string + PypiRegistryConfig: + properties: + registryUrl: string + username: string + password: string + packageName: string + pypiMetadata: optional + RubyGemsRegistryConfig: + properties: + registryUrl: string + apiKey: string + packageName: string + NugetRegistryConfig: + properties: + registryUrl: string + apiKey: string + packageName: string + PostmanConfig: + properties: + apiKey: string + workspaceId: string + GeneratorEnvironment: + union: + local: {} + remote: RemoteGeneratorEnvironment + discriminant: + name: type + value: _type + RemoteGeneratorEnvironment: + properties: + coordinatorUrl: string + coordinatorUrlV2: string + id: logging.TaskId diff --git a/.mock/definition/logging.yml b/.mock/definition/logging.yml new file mode 100644 index 0000000..f4d4647 --- /dev/null +++ b/.mock/definition/logging.yml @@ -0,0 +1,82 @@ +types: + TaskId: string + GeneratorUpdate: + union: + init: InitUpdate + initV2: InitUpdateV2 + log: LogUpdate + publishing: + type: PackageCoordinate + key: publishing + published: + type: PackageCoordinate + key: published + exitStatusUpdate: + type: ExitStatusUpdate + key: exitStatusUpdate + discriminant: + name: type + value: _type + InitUpdate: + properties: + packagesToPublish: list + InitUpdateV2: + properties: + publishingToRegistry: optional + RegistryType: + enum: + - NPM + - MAVEN + - PYPI + - RUBYGEMS + - NUGET + LogUpdate: + properties: + level: LogLevel + message: string + LogLevel: + enum: + - DEBUG + - INFO + - WARN + - ERROR + PackageCoordinate: + union: + npm: NpmCoordinate + maven: MavenCoordinate + discriminant: + name: type + value: _type + NpmCoordinate: + properties: + name: string + version: string + MavenCoordinate: + properties: + group: string + artifact: string + version: string + ExitStatusUpdate: + union: + successful: SuccessfulStatusUpdate + error: ErrorExitStatusUpdate + discriminant: + name: type + value: _type + SuccessfulStatusUpdate: + properties: + zipFilename: optional + ErrorExitStatusUpdate: + properties: + message: string +service: + auth: false + base-path: /api/generator-logging + endpoints: + sendUpdate: + path: /{taskId} + path-parameters: + taskId: TaskId + request: + body: + type: list diff --git a/.mock/definition/readme.yml b/.mock/definition/readme.yml new file mode 100644 index 0000000..9196ca4 --- /dev/null +++ b/.mock/definition/readme.yml @@ -0,0 +1,110 @@ +imports: + logging: logging.yml +types: + GenerateReadmeRequest: + docs: | + The standard sections included in every generated README.md + + # {{title}} + {{badge}} [Fern Badge] + + {{summary}} + + ## API Documentation + + API Reference Documentation is available {{here}}. + + ## Installation + + {{installation}} + + ## Usage + + {{usage}} + + ## Async Client + + {{asyncUsage}} + + ## Environments + + {{environments}} + + ## Custom URL + + {{customUrl}} + + ## Handling Errors + + {{errors}} + + ## Advanced: Setting Timeouts + + {{timeouts}} + + ## Advanced: Request Options + + {{requestOptions}}} + + ## Beta Status + + Some info about beta status. + + ## Contributing + + Some info about contributing. + properties: + title: + type: string + docs: The title (e.g. Acme Python Library ...) + badge: + type: optional + docs: Badges rendered alongside the standard Fern badge + summary: + type: string + docs: >- + The summary included below the badges (e.g. The Acme Python library + provides ...) + requirements: + type: list + docs: Each requirement is rendered as a bulleted list + installation: + type: optional + docs: The installation steps + usage: + type: string + docs: Section describing how to instantiate the client (i.e. a code snippet) + asyncUsage: + type: optional + docs: Section describing how to instantiate an async client + timeouts: + type: optional + docs: Section describing how to set timeouts + environments: + type: optional + docs: >- + If multiple environments, a section for how to specify multiple + environments + customUrl: + type: optional + docs: Section describing how to set a custom url + requestOptions: + type: optional + docs: Section describing how to set request options + BadgeType: + enum: + - NPM + - MAVEN + - PYPI + - GO + - RUBYGEMS + - NUGET +service: + auth: false + base-path: /api/readme + endpoints: + generateReadme: + path: /{taskId} + path-parameters: + taskId: logging.TaskId + request: GenerateReadmeRequest diff --git a/.mock/definition/snippets.yml b/.mock/definition/snippets.yml new file mode 100644 index 0000000..129c074 --- /dev/null +++ b/.mock/definition/snippets.yml @@ -0,0 +1,182 @@ +types: + TypeId: string + Snippets: + docs: The code snippets defined in the API + properties: + types: + type: map + docs: The type snippets defined by by the API + endpoints: + type: list + docs: The endpoint snippets defined by the API + Endpoint: + properties: + example_identifier: + type: optional + docs: The id of the example used to create the snippet. + id: EndpointIdentifier + snippet: EndpointSnippet + EndpointIdentifier: + properties: + path: EndpointPath + method: EndpointMethod + identifier_override: + type: optional + docs: > + The ID for the endpoint as declared within the IR, this is a unique + name for the endpoint, whereas path and + + method are not (specifically for the fern definition, consider chat + and chat stream). This is optional to + + remain backcompat with old snippets of yore. + EndpointPath: + docs: The relative path for an endpont (e.g. `/users/{userId}`) + type: string + EndpointMethod: + enum: + - PUT + - POST + - GET + - PATCH + - DELETE + EndpointSnippet: + docs: >- + Defines a variety of different formats for an individual endpoint's + snippet + union: + typescript: TypescriptEndpointSnippet + python: PythonEndpointSnippet + java: JavaEndpointSnippet + go: GoEndpointSnippet + ruby: RubyEndpointSnippet + TypescriptEndpointSnippet: + properties: + client: + type: string + docs: | + A full endpoint snippet, including the client instantiation, e.g. + + import { AcmeClient, Acme } from '@acme/acme-node-client'; + + const acme = new AcmeClient({ + apiKey: 'YOUR_API_KEY', + }); + await acme.admin.update({ + submission_id: "submission-12o3uds", + request: Acme.RunningSubmissionState.QUEUEING_SUBMISSION, + }); + RubyEndpointSnippet: + properties: + client: + type: string + docs: | + A full endpoint snippet, including the client instantiation, e.g. + + require "acme" + + acme = Acme::Client.new( + apiKey: 'YOUR_API_KEY' + ) + acme.admin.update( + submission_id: "submission-12o3uds", + request: Acme::RunningSubmissionState::QUEUEING_SUBMISSION + ) + PythonEndpointSnippet: + properties: + sync_client: + type: string + docs: | + A full endpoint snippet, including the sync client instantiation, e.g. + + from acme import RunningSubmissionState + from acme.client import Acme + + client = Acme(api_key="...") + client.admin.update( + submission_id="submission-12o3uds", + request=RunningSubmissionState.QUEUEING_SUBMISSION, + ) + async_client: + type: string + docs: > + A full endpoint snippet, including the async client instantiation, + e.g. + + + from acme import RunningSubmissionState + + from acme.client import AsyncAcme + + + client = AsyncAcme(api_key="...") + + await client.admin.update( + submission_id="submission-12o3uds", + request=RunningSubmissionState.QUEUEING_SUBMISSION, + ) + JavaEndpointSnippet: + properties: + sync_client: + type: string + docs: | + A full endpoint snippet, including the sync client instantiation, e.g. + + import com.acme.AcmeApiClient; + import com.acme.resources.types.RunningSubmissionState; + + AcmeClient acmeClient = AcmeClient.builder() + .apiKey("...") + .build(); + + acmeClient.admin().create( + "submission-12o3uds", + AdminUpdateRequest.builder() + .submissionState(RunningSubmissionState.QUEUEING_SUBMISSION) + .build()); + async_client: + type: string + docs: > + A full endpoint snippet, including the async client instantiation, + e.g. + + + import com.acme.AcmeApiClient; + + import com.acme.resources.types.RunningSubmissionState; + + + AcmeClient acmeClient = AcmeClient.builder() + .apiKey("API_KEY") + .build(); + + acmeClient.admin().create( + "submission-12o3uds", + AdminUpdateRequest.builder() + .submissionState(RunningSubmissionState.QUEUEING_SUBMISSION) + .build()); + GoEndpointSnippet: + properties: + client: + type: string + docs: | + A full endpoint snippet, including the client instantiation, e.g. + + import ( + "context" + "fmt" + + acme "github.com/acme/acme-go" + acmeclient "github.com/acme/acme-go/client" + ) + + client := acmeclient.NewClient( + acmeclient.WithApiKey("..."), + ) + client.Admin.Update( + context.TODO(), + "submission-12o3uds", + &acme.AdminUpdateRequest{ + SubmissionState: acme.RunningSubmissionStateQueuingSubmission, + }, + ) diff --git a/.mock/fern.config.json b/.mock/fern.config.json new file mode 100644 index 0000000..eb03ee1 --- /dev/null +++ b/.mock/fern.config.json @@ -0,0 +1,4 @@ +{ + "organization" : "fern", + "version" : "0.37.6" +} \ No newline at end of file