fix: resolve CI linting and code quality issues
- Remove unused imports across all generator files - Remove unused variables (spec, url_params, query_params, test_name) - Fix f-strings without placeholders in auth.py and go.py - Fix duplicate BASIC auth handling with wrong indentation - Add missing pytest fixtures (sample_openapi_spec, temp_spec_file, temp_json_spec_file) - Add missing TemplateRenderError import to generator files
This commit is contained in:
@@ -59,3 +59,193 @@ def flavor_manager():
|
||||
"""Provide the flavor manager."""
|
||||
from regex_humanizer.flavors import get_flavor_manager
|
||||
return get_flavor_manager()
|
||||
|
||||
|
||||
SAMPLE_OPENAPI_SPEC = {
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"title": "Test Pet Store API",
|
||||
"version": "1.0.0",
|
||||
"description": "A sample API for testing purposes"
|
||||
},
|
||||
"servers": [
|
||||
{"url": "https://api.example.com/v1"}
|
||||
],
|
||||
"paths": {
|
||||
"/pets": {
|
||||
"get": {
|
||||
"summary": "List all pets",
|
||||
"description": "Returns a list of pets",
|
||||
"operationId": "listPets",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "limit",
|
||||
"in": "query",
|
||||
"description": "Maximum number of pets to return",
|
||||
"required": False,
|
||||
"schema": {"type": "integer", "default": 10}
|
||||
},
|
||||
{
|
||||
"name": "status",
|
||||
"in": "query",
|
||||
"description": "Filter by pet status",
|
||||
"required": False,
|
||||
"schema": {"type": "string", "enum": ["available", "pending", "sold"]}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A list of pets",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/components/schemas/Pet"}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"summary": "Create a new pet",
|
||||
"description": "Creates a new pet in the store",
|
||||
"operationId": "createPet",
|
||||
"requestBody": {
|
||||
"required": True,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {"$ref": "#/components/schemas/Pet"}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Pet created successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {"$ref": "#/components/schemas/Pet"}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/pets/{petId}": {
|
||||
"get": {
|
||||
"summary": "Get a pet by ID",
|
||||
"description": "Returns a single pet",
|
||||
"operationId": "getPetById",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "ID of the pet to retrieve",
|
||||
"required": True,
|
||||
"schema": {"type": "string"}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful operation",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {"$ref": "#/components/schemas/Pet"}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Pet not found"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"summary": "Delete a pet",
|
||||
"description": "Deletes a pet from the store",
|
||||
"operationId": "deletePet",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "petId",
|
||||
"in": "path",
|
||||
"description": "ID of the pet to delete",
|
||||
"required": True,
|
||||
"schema": {"type": "string"}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "Pet deleted successfully"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"Pet": {
|
||||
"type": "object",
|
||||
"required": ["name", "status"],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"example": "Fluffy"
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": ["available", "pending", "sold"],
|
||||
"description": "Pet status in the store"
|
||||
},
|
||||
"categoryId": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"categoryName": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securitySchemes": {
|
||||
"ApiKeyAuth": {
|
||||
"type": "apiKey",
|
||||
"in": "header",
|
||||
"name": "X-API-Key"
|
||||
},
|
||||
"BearerAuth": {
|
||||
"type": "http",
|
||||
"scheme": "bearer",
|
||||
"bearerFormat": "JWT"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_openapi_spec():
|
||||
"""Provide a sample OpenAPI specification for testing."""
|
||||
return SAMPLE_OPENAPI_SPEC
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def temp_spec_file(sample_openapi_spec, tmp_path):
|
||||
"""Create a temporary YAML file with a sample OpenAPI spec."""
|
||||
import yaml
|
||||
file_path = tmp_path / "test_spec.yaml"
|
||||
with open(file_path, 'w') as f:
|
||||
yaml.dump(sample_openapi_spec, f)
|
||||
return file_path
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def temp_json_spec_file(sample_openapi_spec, tmp_path):
|
||||
"""Create a temporary JSON file with a sample OpenAPI spec."""
|
||||
import json
|
||||
file_path = tmp_path / "test_spec.json"
|
||||
with open(file_path, 'w') as f:
|
||||
json.dump(sample_openapi_spec, f, indent=2)
|
||||
return file_path
|
||||
|
||||
Reference in New Issue
Block a user