Skip to content

Conversation

@cowboy-bebug
Copy link

@cowboy-bebug cowboy-bebug commented Nov 19, 2025

Hi there 👋

I use the tool extensively at work and thought it'd be really great to generate some consts based on the JSON schema keywords.

This PR adds features to handle the keywords such as minimum, maximum, etc.:

paths:
  /users:
    get:
      operationId: listUsers
      summary: List users with pagination and filtering
      description: Demonstrates inline parameter constraints generating constants
      parameters:
        - in: query
          name: limit
          description: Maximum number of items to return
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20

components:
  schemas:
    Username:
      type: string
      minLength: 3
      maxLength: 20
      default: "guest"

as constants:

// Constraint constants for ListUsersLimit.
const (
	ListUsersLimitMinimum int = 1
	ListUsersLimitMaximum int = 100
	ListUsersLimitDefault int = 20
)

// Constraint constants for Username.
const (
	UsernameDefault   string = "guest"
	UsernameMinLength uint64 = 3
	UsernameMaxLength uint64 = 20
)

I didn't find any relevant / related issues. Let me know if this is something valuable to you guys as well 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant