Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple custom code samples for the same language / TypeScript support #1035

Closed
m-murasovs opened this issue Dec 4, 2024 · 1 comment
Closed

Comments

@m-murasovs
Copy link

m-murasovs commented Dec 4, 2024

What I'm trying to achieve:

I want to add code examples that use both our JavaScript API client and the TypeScript clients using the x-codeSamples approach.

The issue

Since there's no TS support for now (is there a plan to add this btw?), I wanted to add multiple examples, just like there are for each language by default (e.g. JavaScript has Fetch, jQuery, and XHR), but I haven't been able to find a way that works.

The question

Is it possible to add multiple code snippets using x-codeSamples?

Thanks in advance!

@sserrata
Copy link
Member

sserrata commented Dec 9, 2024

Hi @m-murasovs, yes x-codeSamples are supported. Please refer to the demo for a live example. See #1036 for additional discussion on this topic.

@sserrata sserrata closed this as completed Dec 9, 2024
janbuchar added a commit to apify/apify-docs that referenced this issue Dec 10, 2024
Here are the first two code samples for the API docs. These are for the
JS client and are a tentative proposal. When we've agreed on how they
should look, I'll also add the ones for the Python client.

**Note**: The Palo Alto plugin currently doesn't support TypeScript and
there's no straightforward way to add multiple custom code samples for
the same language (I thought we could have JS and TS client samples
under the JavaScript bit).
I have created an issue asking about this on the plugin's repo:
PaloAltoNetworks/docusaurus-openapi-docs#1035

**Note 2**: For the POST request, as mentioned by @netmilk , it would be
nice to have the request body present, but that would be complicated,
since the schema isn't available in the examples, and would make the
testing harder. I think it's not so bad, though, since the request body
is shown right under the code example, so it's quite easy to find.

So, on the new docs it will look like this:
![CleanShot 2024-12-04 at 16 06
42@2x](https://github.com/user-attachments/assets/d4c00c7b-d5e3-476c-bb3c-61fa9e1ea0e3)

And in the old/current docs like this: (I had to fix the background
color)
![CleanShot 2024-12-04 at 16 27
02@2x](https://github.com/user-attachments/assets/25279a78-8738-433d-bf31-54aee9205d69)
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

No branches or pull requests

2 participants