pdevito3 / craftsman

A .NET scaffolding tool to help you stop worrying about boilerplate and focus on your business logic 🚀
https://wrapt.dev
MIT License
1.12k stars 65 forks source link

Naming inconsistency of Swagger Auth Scopes #119

Closed Ken1Nil closed 1 year ago

Ken1Nil commented 1 year ago

When scaffolding a project with ProjectName (for example: "MyCraftsmanManagement") containing PascalCase naming style, and not supplying a PolicyName in Template, SwaggerBuilder makes the Scope name "my_craftsman_management" with ProjectName.Underscore().

This ignores whatever is used in

Environment:
    AuthSettings: 
       Audience: craftsman_management

Would be helpful if the Scopes for Swagger Auth Documentation would use the Audience: property instead of MyProjectName -> my_project_name

Steps to reproduce

Using this template you can generate the same:

DomainName: MyCraftsmanManagementWithAuth
BoundedContexts:
- ProjectName: MyCraftsmanManagement
  Port: 5375
  DbContext:
    ContextName: MyCraftsmanDbContext
    DatabaseName: MyCraftsmanManagement
    Provider: postgres
  Entities:
  - Name: Craft
    Features:
    - Type: GetList
      IsProtected: true
      PermissionName: CanReadCrafts
    Properties:
    - Name: Name
      Type: string
      CanFilter: true
      CanSort: true
  Environment:
    AuthSettings:
      Authority: http://localhost:3255/realms/DevRealm
      Audience: craftsman_management
      AuthorizationUrl: http://localhost:3255/realms/DevRealm/protocol/openid-connect/auth
      TokenUrl: http://localhost:3255/realms/DevRealm/protocol/openid-connect/token
      ClientId: craftsman_management.swagger
      ClientSecret: 974d6f71-d41b-4601-9a7a-a33081f80687
    BrokerSettings:
        Host: localhost
        VirtualHost: /
        Username: guest
        Password: guest
  SwaggerConfig:
      Title: MyCraftsmanManagement API
      SwaggerEndpointName: MyCraftsmanManagement API
      AddSwaggerComments: true

Further technical details

Craftsman version (dotnet tool list -g): craftsman 0.21.1

pdevito3 commented 1 year ago

Yeah, agreed. This was a while ago, but I think that was meant to be a fallback to allow for lighter configs

Thanks for the callout. I'll try and get this in next release

pdevito3 commented 1 year ago

Just realized i forgot this in the release yesterday. Pushing an update to nuget now.

Thanks again!