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

Enable pydantic v2 (GSI 448) #173

Merged
merged 5 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ repos:
- id: debug-statements
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.291
rev: v0.1.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.10.1
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.6.1
hooks:
- id: mypy
args: [--no-warn-unused-ignores]
78 changes: 71 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,83 @@ The service requires the following configuration parameters:

- **`docs_url`** *(string)*: Path to host the swagger documentation. This is relative to the specified host and port. Default: `"/docs"`.

- **`cors_allowed_origins`** *(array)*: A list of origins that should be permitted to make cross-origin requests. By default, cross-origin requests are not allowed. You can use ['*'] to allow any origin.
- **`cors_allowed_origins`**: A list of origins that should be permitted to make cross-origin requests. By default, cross-origin requests are not allowed. You can use ['*'] to allow any origin. Default: `null`.

- **Items** *(string)*
- **Any of**

- **`cors_allow_credentials`** *(boolean)*: Indicate that cookies should be supported for cross-origin requests. Defaults to False. Also, cors_allowed_origins cannot be set to ['*'] for credentials to be allowed. The origins must be explicitly specified.
- *array*

- **`cors_allowed_methods`** *(array)*: A list of HTTP methods that should be allowed for cross-origin requests. Defaults to ['GET']. You can use ['*'] to allow all standard methods.
- **Items** *(string)*

- **Items** *(string)*
- *null*

- **`cors_allowed_headers`** *(array)*: A list of HTTP request headers that should be supported for cross-origin requests. Defaults to []. You can use ['*'] to allow all headers. The Accept, Accept-Language, Content-Language and Content-Type headers are always allowed for CORS requests.

- **Items** *(string)*
Examples:

```json
[
"https://example.org",
"https://www.example.org"
]
```


- **`cors_allow_credentials`**: Indicate that cookies should be supported for cross-origin requests. Defaults to False. Also, cors_allowed_origins cannot be set to ['*'] for credentials to be allowed. The origins must be explicitly specified. Default: `null`.

- **Any of**

- *boolean*

- *null*


Examples:

```json
[
"https://example.org",
"https://www.example.org"
]
```


- **`cors_allowed_methods`**: A list of HTTP methods that should be allowed for cross-origin requests. Defaults to ['GET']. You can use ['*'] to allow all standard methods. Default: `null`.

- **Any of**

- *array*

- **Items** *(string)*

- *null*


Examples:

```json
[
"*"
]
```


- **`cors_allowed_headers`**: A list of HTTP request headers that should be supported for cross-origin requests. Defaults to []. You can use ['*'] to allow all headers. The Accept, Accept-Language, Content-Language and Content-Type headers are always allowed for CORS requests. Default: `null`.

- **Any of**

- *array*

- **Items** *(string)*

- *null*


Examples:

```json
[]
```


- **`service_name`** *(string)*: Default: `"my_microservice"`.

Expand Down
174 changes: 86 additions & 88 deletions config_schema.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
{
"title": "ModSettings",
"additionalProperties": false,
"description": "Modifies the orginal Settings class provided by the user",
"type": "object",
"properties": {
"host": {
"title": "Host",
"description": "IP of the host.",
"default": "127.0.0.1",
"env_names": [
"my_microservice_host"
],
"description": "IP of the host.",
"title": "Host",
"type": "string"
},
"port": {
"title": "Port",
"description": "Port to expose the server on the specified host",
"default": 8080,
"env_names": [
"my_microservice_port"
],
"description": "Port to expose the server on the specified host",
"title": "Port",
"type": "integer"
},
"log_level": {
"title": "Log Level",
"description": "Controls the verbosity of the log.",
"default": "info",
"env_names": [
"my_microservice_log_level"
],
"description": "Controls the verbosity of the log.",
"enum": [
"critical",
"error",
Expand All @@ -36,128 +25,137 @@
"debug",
"trace"
],
"title": "Log Level",
"type": "string"
},
"auto_reload": {
"title": "Auto Reload",
"description": "A development feature. Set to `True` to automatically reload the server upon code changes",
"default": false,
"env_names": [
"my_microservice_auto_reload"
],
"description": "A development feature. Set to `True` to automatically reload the server upon code changes",
"title": "Auto Reload",
"type": "boolean"
},
"workers": {
"title": "Workers",
"description": "Number of workers processes to run.",
"default": 1,
"env_names": [
"my_microservice_workers"
],
"description": "Number of workers processes to run.",
"title": "Workers",
"type": "integer"
},
"api_root_path": {
"title": "Api Root Path",
"description": "Root path at which the API is reachable. This is relative to the specified host and port.",
"default": "/",
"env_names": [
"my_microservice_api_root_path"
],
"description": "Root path at which the API is reachable. This is relative to the specified host and port.",
"title": "Api Root Path",
"type": "string"
},
"openapi_url": {
"title": "Openapi Url",
"description": "Path to get the openapi specification in JSON format. This is relative to the specified host and port.",
"default": "/openapi.json",
"env_names": [
"my_microservice_openapi_url"
],
"description": "Path to get the openapi specification in JSON format. This is relative to the specified host and port.",
"title": "Openapi Url",
"type": "string"
},
"docs_url": {
"title": "Docs Url",
"description": "Path to host the swagger documentation. This is relative to the specified host and port.",
"default": "/docs",
"env_names": [
"my_microservice_docs_url"
],
"description": "Path to host the swagger documentation. This is relative to the specified host and port.",
"title": "Docs Url",
"type": "string"
},
"cors_allowed_origins": {
"title": "Cors Allowed Origins",
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "A list of origins that should be permitted to make cross-origin requests. By default, cross-origin requests are not allowed. You can use ['*'] to allow any origin.",
"example": [
"https://example.org",
"https://www.example.org"
"examples": [
[
"https://example.org",
"https://www.example.org"
]
],
"env_names": [
"my_microservice_cors_allowed_origins"
],
"type": "array",
"items": {
"type": "string"
}
"title": "Cors Allowed Origins"
},
"cors_allow_credentials": {
"title": "Cors Allow Credentials",
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"description": "Indicate that cookies should be supported for cross-origin requests. Defaults to False. Also, cors_allowed_origins cannot be set to ['*'] for credentials to be allowed. The origins must be explicitly specified.",
"example": [
"https://example.org",
"https://www.example.org"
],
"env_names": [
"my_microservice_cors_allow_credentials"
"examples": [
[
"https://example.org",
"https://www.example.org"
]
],
"type": "boolean"
"title": "Cors Allow Credentials"
},
"cors_allowed_methods": {
"title": "Cors Allowed Methods",
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "A list of HTTP methods that should be allowed for cross-origin requests. Defaults to ['GET']. You can use ['*'] to allow all standard methods.",
"example": [
"*"
],
"env_names": [
"my_microservice_cors_allowed_methods"
"examples": [
[
"*"
]
],
"type": "array",
"items": {
"type": "string"
}
"title": "Cors Allowed Methods"
},
"cors_allowed_headers": {
"title": "Cors Allowed Headers",
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "A list of HTTP request headers that should be supported for cross-origin requests. Defaults to []. You can use ['*'] to allow all headers. The Accept, Accept-Language, Content-Language and Content-Type headers are always allowed for CORS requests.",
"example": [],
"env_names": [
"my_microservice_cors_allowed_headers"
"examples": [
[]
],
"type": "array",
"items": {
"type": "string"
}
"title": "Cors Allowed Headers"
},
"service_name": {
"title": "Service Name",
"default": "my_microservice",
"env_names": [
"my_microservice_service_name"
],
"title": "Service Name",
"type": "string"
},
"language": {
"title": "Language",
"default": "Croatian",
"env_names": [
"my_microservice_language"
],
"enum": [
"Greek",
"Croatian",
"French",
"German"
],
"title": "Language",
"type": "string"
}
},
"additionalProperties": false
"title": "ModSettings",
"type": "object"
}
2 changes: 1 addition & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ components:
info:
title: FastAPI
version: 0.1.0
openapi: 3.0.2
openapi: 3.1.0
paths:
/:
get:
Expand Down
Loading