-
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: multi line descriptions for the pydantic preset in python (#1592)
- Loading branch information
1 parent
4c2eec1
commit 2c46b94
Showing
4 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
PythonGenerator, | ||
PYTHON_PYDANTIC_PRESET | ||
} from '../../../../src/generators/python'; | ||
|
||
describe('PYTHON_PYDANTIC_PRESET', () => { | ||
let generator: PythonGenerator; | ||
|
||
beforeEach(() => { | ||
generator = new PythonGenerator({ | ||
presets: [PYTHON_PYDANTIC_PRESET] | ||
}); | ||
}); | ||
|
||
test('should render pydantic for class', async () => { | ||
const doc = { | ||
title: 'Test', | ||
type: 'object', | ||
properties: { | ||
prop: { | ||
description: `test | ||
multi | ||
line | ||
description`, | ||
type: 'string' | ||
} | ||
} | ||
}; | ||
|
||
const models = await generator.generate(doc); | ||
expect(models).toHaveLength(1); | ||
expect(models[0].result).toMatchSnapshot(); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
test/generators/python/presets/__snapshots__/Pydantic.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`PYTHON_PYDANTIC_PRESET should render pydantic for class 1`] = ` | ||
"class Test(BaseModel): | ||
prop: Optional[str] = Field(alias='''test | ||
multi | ||
line | ||
description''') | ||
additionalProperties: Optional[dict[Any, Any]] = Field() | ||
" | ||
`; |