# Schema

## List all credential schemas

> Retrieves all credential schemas

```json
{"openapi":"3.0.0","info":{"title":"issuer-service","version":"1.0.0-rc2"},"servers":[{"url":"/"}],"security":[],"paths":{"/api/v1/schemas":{"get":{"operationId":"GetSchemaCollection","responses":{"200":{"description":"Found","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/SchemaResponseDto"},"type":"array"}}}},"400":{"description":"Bad Request - Invalid query parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponseDto"}}}}},"description":"Retrieves all credential schemas","summary":"List all credential schemas","tags":["Schema"],"parameters":[{"description":"Filter by schema type","in":"query","name":"type","required":false,"schema":{"type":"string"}},{"description":"Filter by schema name","in":"query","name":"name","required":false,"schema":{"type":"string"}},{"description":"Filter by schema version","in":"query","name":"version","required":false,"schema":{"format":"double","type":"number"}},{"description":"Sort field","in":"query","name":"sortBy","required":false,"schema":{"type":"string","enum":["type","name","version"]}},{"description":"Sort order","in":"query","name":"sortOrder","required":false,"schema":{"$ref":"#/components/schemas/SortOrder"}}]}}},"components":{"schemas":{"SchemaResponseDto":{"description":"Response DTO for schema operations","properties":{"id":{"type":"string","description":"Unique identifier of the schema"},"type":{"type":"string","description":"Schema type"},"name":{"type":"string","description":"Schema name"},"version":{"type":"number","format":"double","description":"Schema version"},"schemaUri":{"type":"string","description":"Schema URI"},"schemaBody":{"description":"Schema body"}},"required":["id","type","name","version"],"type":"object","additionalProperties":false},"ErrorResponseDto":{"description":"Extended error response with HTTP details","properties":{"name":{"type":"string","description":"Error name"},"message":{"type":"string","description":"Error message"},"code":{"type":"number","format":"double","description":"Error code"},"statusCode":{"type":"number","format":"double","description":"HTTP status code"},"httpCode":{"type":"number","format":"double","description":"HTTP code"},"method":{"type":"string","description":"HTTP method"},"path":{"type":"string","description":"Request path"},"stack":{"type":"string","description":"Stack trace (tylko w środowisku deweloperskim)"}},"required":["name","message","code","statusCode","httpCode","method","path"],"type":"object","additionalProperties":false},"SortOrder":{"enum":["ASC","DESC"],"type":"string"}}}}
```

## Create a new credential schema

> Creates a new credential schema

```json
{"openapi":"3.0.0","info":{"title":"issuer-service","version":"1.0.0-rc2"},"servers":[{"url":"/"}],"security":[{"clientSecret":[]}],"components":{"securitySchemes":{"clientSecret":{"type":"apiKey","name":"x-client-secret","in":"header"}},"schemas":{"SchemaResponseDto":{"description":"Response DTO for schema operations","properties":{"id":{"type":"string","description":"Unique identifier of the schema"},"type":{"type":"string","description":"Schema type"},"name":{"type":"string","description":"Schema name"},"version":{"type":"number","format":"double","description":"Schema version"},"schemaUri":{"type":"string","description":"Schema URI"},"schemaBody":{"description":"Schema body"}},"required":["id","type","name","version"],"type":"object","additionalProperties":false},"ErrorResponseDto":{"description":"Extended error response with HTTP details","properties":{"name":{"type":"string","description":"Error name"},"message":{"type":"string","description":"Error message"},"code":{"type":"number","format":"double","description":"Error code"},"statusCode":{"type":"number","format":"double","description":"HTTP status code"},"httpCode":{"type":"number","format":"double","description":"HTTP code"},"method":{"type":"string","description":"HTTP method"},"path":{"type":"string","description":"Request path"},"stack":{"type":"string","description":"Stack trace (tylko w środowisku deweloperskim)"}},"required":["name","message","code","statusCode","httpCode","method","path"],"type":"object","additionalProperties":false},"CreateSchemaRequestDto":{"description":"Request DTO for creating a new schema","properties":{"name":{"type":"string","description":"Name of the schema"},"type":{"type":"string","description":"Type of the schema"},"version":{"type":"number","format":"double","description":"Schema version"},"credentialSubject":{"$ref":"#/components/schemas/CredentialSubject","description":"Credential subject definition\nSchema fields that define the structure of the credential"}},"required":["name","type","credentialSubject"],"type":"object","additionalProperties":false},"CredentialSubject":{"$ref":"#/components/schemas/Record_string.unknown_"},"Record_string.unknown_":{"properties":{},"additionalProperties":{},"type":"object","description":"Construct a type with a set of properties K of type T"}}},"paths":{"/api/v1/schemas":{"post":{"operationId":"CreateSchema","responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SchemaResponseDto"}}}},"400":{"description":"Bad Request - Invalid input parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponseDto"}}}},"401":{"description":"Unauthorized - Invalid client secret","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponseDto"}}}},"409":{"description":"Conflict - Schema already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponseDto"}}}}},"description":"Creates a new credential schema","summary":"Create a new credential schema","tags":["Schema"],"parameters":[],"requestBody":{"description":"Schema definition including name, type, version and credential subject","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSchemaRequestDto","description":"Schema definition including name, type, version and credential subject"}}}}}}}}
```

## Get a schema by ID

> Retrieves a specific credential schema by ID

```json
{"openapi":"3.0.0","info":{"title":"issuer-service","version":"1.0.0-rc2"},"servers":[{"url":"/"}],"security":[],"paths":{"/api/v1/schemas/{id}":{"get":{"operationId":"GetSchemaById","responses":{"200":{"description":"Found","content":{"application/json":{"schema":{"additionalProperties":false,"type":"object"}}}},"400":{"description":"Bad Request - Invalid schema ID format","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponseDto"}}}},"404":{"description":"Not Found - Schema with given ID does not exist","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponseDto"}}}}},"description":"Retrieves a specific credential schema by ID","summary":"Get a schema by ID","tags":["Schema"],"parameters":[{"description":"Schema ID to retrieve","in":"path","name":"id","required":true,"schema":{"type":"string"}}]}}},"components":{"schemas":{"ErrorResponseDto":{"description":"Extended error response with HTTP details","properties":{"name":{"type":"string","description":"Error name"},"message":{"type":"string","description":"Error message"},"code":{"type":"number","format":"double","description":"Error code"},"statusCode":{"type":"number","format":"double","description":"HTTP status code"},"httpCode":{"type":"number","format":"double","description":"HTTP code"},"method":{"type":"string","description":"HTTP method"},"path":{"type":"string","description":"Request path"},"stack":{"type":"string","description":"Stack trace (tylko w środowisku deweloperskim)"}},"required":["name","message","code","statusCode","httpCode","method","path"],"type":"object","additionalProperties":false}}}}
```

## Delete a schema by ID

> Deletes a specific credential schema

```json
{"openapi":"3.0.0","info":{"title":"issuer-service","version":"1.0.0-rc2"},"servers":[{"url":"/"}],"security":[{"clientSecret":[]}],"components":{"securitySchemes":{"clientSecret":{"type":"apiKey","name":"x-client-secret","in":"header"}},"schemas":{"ErrorResponseDto":{"description":"Extended error response with HTTP details","properties":{"name":{"type":"string","description":"Error name"},"message":{"type":"string","description":"Error message"},"code":{"type":"number","format":"double","description":"Error code"},"statusCode":{"type":"number","format":"double","description":"HTTP status code"},"httpCode":{"type":"number","format":"double","description":"HTTP code"},"method":{"type":"string","description":"HTTP method"},"path":{"type":"string","description":"Request path"},"stack":{"type":"string","description":"Stack trace (tylko w środowisku deweloperskim)"}},"required":["name","message","code","statusCode","httpCode","method","path"],"type":"object","additionalProperties":false}}},"paths":{"/api/v1/schemas/{id}":{"delete":{"operationId":"DeleteSchema","responses":{"204":{"description":"No Content"},"400":{"description":"Bad Request - Invalid schema ID format","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponseDto"}}}},"401":{"description":"Unauthorized - Invalid client secret","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponseDto"}}}},"404":{"description":"Not Found - Schema with specified ID not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponseDto"}}}},"409":{"description":"Conflict - Schema is in use by credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponseDto"}}}}},"description":"Deletes a specific credential schema","summary":"Delete a schema by ID","tags":["Schema"],"parameters":[{"description":"Schema ID to delete","in":"path","name":"id","required":true,"schema":{"type":"string"}}]}}}}
```
