Skip to content

Commit

Permalink
fix: Fix code-samples deserialization from openapi-overrides.yml (#3170)
Browse files Browse the repository at this point in the history
* fix: Fix code-sampleas deserialization from openapi-overrides.yml

* ruby

* more generation

* run java seed

---------

Co-authored-by: armandobelardo <[email protected]>
  • Loading branch information
mscolnick and armandobelardo authored Mar 15, 2024
1 parent 5cb5b95 commit a4e43ab
Show file tree
Hide file tree
Showing 481 changed files with 17,550 additions and 127 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test-definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ on:
paths:
- "packages/**"
- "test-definitions/**"
- "test-definitions-openapi/**"
branches:
- main
pull_request:
paths:
- "packages/**"
- "test-definitions/**"
- "test-definitions-openapi/**"
branches:
- main

Expand Down Expand Up @@ -41,3 +43,5 @@ jobs:
yarn workspace @fern-api/cli dist:cli:dev
cd test-definitions
FERN_NO_VERSION_REDIRECTION=true node $(yarn workspace @fern-api/cli bin fern:dev) check
cd ../test-definitions-openapi
FERN_NO_VERSION_REDIRECTION=true node $(yarn workspace @fern-api/cli bin fern:dev) check
22 changes: 11 additions & 11 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
138 changes: 69 additions & 69 deletions fern/docs/pages/overview/define-your-api/openapi/extensions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ components:

## Global headers
At times, your API will leverage certain headers for every endpoint, or the majority of them, we call these "global headers". For convenience, generated Fern SDKs
expose "global headers" to easily be updated on API calls. Take for example an API key, if we declare the API key as a global header, a user will be able to
expose "global headers" to easily be updated on API calls. Take for example an API key, if we declare the API key as a global header, a user will be able to
plug theirs in easily:
```python
import os
Expand Down Expand Up @@ -266,13 +266,13 @@ export interface Person { # <---- Overridden name
}
```

## Parameter names
## Parameter names

The `x-fern-parameter-name` extension allows you to customize the variable name of OpenAPI
parameters.
The `x-fern-parameter-name` extension allows you to customize the variable name of OpenAPI
parameters.

For example, if you have a header `X-API-Version`, you may want the parameter
in code to be called `version`.
For example, if you have a header `X-API-Version`, you may want the parameter
in code to be called `version`.

<CodeBlock title="openapi.yml">
```yaml
Expand All @@ -293,7 +293,7 @@ paths:

## Server names

The `x-fern-server-name` extension is used to name your servers.
The `x-fern-server-name` extension is used to name your servers.

<CodeBlock title="openapi.yml">
```yaml
Expand All @@ -320,21 +320,21 @@ export type ExampleEnvironment = typeof ExampleEnvironment.Production;
## Audiences

The `x-fern-audiences` extension is used to mark endpoints with a particular audience
so that you can filter your SDKs and Docs as you would like in Fern.
so that you can filter your SDKs and Docs as you would like in Fern.

In the example below, we have marked the `POST /users` endpoint with the `public` audience.
In the example below, we have marked the `POST /users` endpoint with the `public` audience.

<CodeBlock title="openapi.yml">
```yaml
paths:
/users:
post:
paths:
/users:
post:
x-fern-audiences: # <---- mark with the public audience
- public
operationId: users_create
...
/projects:
post:
/projects:
post:
operationId: projects_create
...
```
Expand All @@ -346,11 +346,11 @@ To filter to the public audience when generating code, update your `generators.y

<CodeBlock title="generators.yml">
```yaml
groups:
sdks:
groups:
sdks:
audiences: # <---- the generators will now be filtered to the public audience
- public
generators:
- public
generators:
- name: fernapi/fern-tyepscript-node-sdk
version: 0.8.8
...
Expand Down Expand Up @@ -460,39 +460,39 @@ variant.

## Ignoring schemas or endpoints

If you want Fern to skip reading any endpoint or schemas, you can use the
`x-fern-ignore` extension.
If you want Fern to skip reading any endpoint or schemas, you can use the
`x-fern-ignore` extension.

To skip an endpoint, you must add `x-fern-ignore: true` at the operation
level.
To skip an endpoint, you must add `x-fern-ignore: true` at the operation
level.

```yaml openapi.yml
```yaml openapi.yml
paths:
/users:
get:
/users:
get:
x-fern-ignore: true # <-----------
...
```

To skip a schema, you msut add `x-fern-ignore: true` at the schema level.
To skip a schema, you msut add `x-fern-ignore: true` at the schema level.

```yaml openapi.yml
components:
schemas:
SchemaToSkip:
```yaml openapi.yml
components:
schemas:
SchemaToSkip:
x-fern-ignore: true # <-----------
...
```

## Overlaying extensions
## Overlaying extensions

Because of the number of tools that use OpenAPI, it may be more convenient to
Because of the number of tools that use OpenAPI, it may be more convenient to
"overlay" your fern specific OpenAPI extensions onto your original definition. \
In order to do this you can use the `x-fern-overrides-filepath` extension.

Below is an example of how someone can overlay the extensions `x-fern-sdk-method-name` and
`x-fern-sdk-group-name` without polluting their original OpenAPI. The combined result is
shown in the third tab.
Below is an example of how someone can overlay the extensions `x-fern-sdk-method-name` and
`x-fern-sdk-group-name` without polluting their original OpenAPI. The combined result is
shown in the third tab.

<CodeBlocks>
<CodeBlock title="openapi.yml">
Expand All @@ -501,7 +501,7 @@ shown in the third tab.
info:
title: User API
version: 1.0.0
x-fern-overrides-filepath: overrides.yml # <---------
x-fern-overrides-filepath: overrides.yml # <---------
paths:
/users:
get:
Expand Down Expand Up @@ -545,72 +545,72 @@ shown in the third tab.

## Request + response examples

While OpenAPI has several fields for examples, there is no easy way
to associate a request with a response. This is expecially useful when
you want to show more than one example in your documentation.
While OpenAPI has several fields for examples, there is no easy way
to associate a request with a response. This is expecially useful when
you want to show more than one example in your documentation.

`x-fern-examples` is an array of examples. Each element of the array
`x-fern-examples` is an array of examples. Each element of the array
can contain `path-parameters`, `query-parameters`, `request` and `response`
examples values that are all associated.
```yaml openapi.yml
paths:
/users/{userId}:
examples values that are all associated.
```yaml openapi.yml
paths:
/users/{userId}:
get:
x-fern-examples:
- path-parameters: # <----- Example 1
userId: user-1234
response:
body:
response:
body:
name: Foo
ssn: 1234
- path-parameters: # <----- Example 2
userId: user-4567
response:
body:
response:
body:
name: Foo
ssn: 4567
components:
schemas:
User:
components:
schemas:
User:
type: object
properties:
name:
properties:
name:
type: string
ssn:
ssn:
type: integer
```

### Code samples

If you'd like to specify custom code samples for your example,
use `code-samples`.
If you'd like to specify custom code samples for your example,
use `code-samples`.

```yaml openapi.yml
paths:
/users/{userId}:
```yaml openapi.yml
paths:
/users/{userId}:
get:
x-fern-examples:
- path-parameters:
- path-parameters:
userId: user-1234
response:
body:
response:
body:
name: Foo
ssn: 1234
code-samples: # <----------- Add your code samples here
sdk: typescript
code: |
import { UserClient } from "...";
- sdk: typescript
code: |
import { UserClient } from "...";
client.users.get("user-1234")
client.users.get("user-1234")
```

If you're on the Fern Starter plan or higher for SDKs you won't have to worry about manually adding code samples! Our generators do that for you.

### Availability

The `x-fern-availability` extension is used to mark the availability of an endpoint. The availability information propagates into the generated Fern Docs website as visual tags.
The `x-fern-availability` extension is used to mark the availability of an endpoint. The availability information propagates into the generated Fern Docs website as visual tags.

The options are:
The options are:
- `beta`
- `generally-available`
- `deprecated`
Expand All @@ -622,7 +622,7 @@ The example below marks that the `POST /pet` endpoint is `deprecated`.
paths:
/pet:
post:
x-fern-availability: deprecated <----
x-fern-availability: deprecated <----
...
```
</CodeBlock>
Expand Down
9 changes: 7 additions & 2 deletions generators/csharp/cli/.mrlint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"type": "library",
"private": true
}
"private": true,
"rules": {
"duplicate-dependencies": {
"exclude": ["@fern-fern/ir-sdk"]
}
}
}
2 changes: 1 addition & 1 deletion generators/ruby/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@fern-api/logger": "workspace:*",
"@fern-api/logging-execa": "workspace:*",
"@fern-fern/generator-exec-sdk": "0.0.619",
"@fern-fern/ir-sdk": "0.0.3294",
"@fern-fern/ir-sdk": "^32",
"tmp-promise": "^3.0.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion generators/ruby/codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"@fern-api/fs-utils": "workspace:*",
"@fern-fern/generator-exec-sdk": "0.0.619",
"@fern-fern/ir-sdk": "0.0.3294",
"@fern-fern/ir-sdk": "^32",
"lodash-es": "^4.17.21"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion generators/ruby/model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@fern-api/ruby-codegen": "workspace:*",
"@fern-api/ruby-generator-cli": "workspace:*",
"@fern-fern/generator-exec-sdk": "0.0.619",
"@fern-fern/ir-sdk": "0.0.3277",
"@fern-fern/ir-sdk": "^32",
"zod": "^3.22.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion generators/ruby/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@fern-api/ruby-codegen": "workspace:*",
"@fern-api/ruby-generator-cli": "workspace:*",
"@fern-fern/generator-exec-sdk": "0.0.619",
"@fern-fern/ir-sdk": "0.0.3294",
"@fern-fern/ir-sdk": "^32",
"lodash-es": "^4.17.21",
"zod": "^3.22.3"
},
Expand Down
Loading

0 comments on commit a4e43ab

Please sign in to comment.